Thanks for the great question! There is no specific rule about how long the Speaker can keep their job but there are some rules about who can be Speaker and how they are chosen. The Speaker of the House of Representatives is elected by the members of the House of Representatives at the start of a new Parliament. Section 35 of the Australian Constitution states the Speaker must be a member of the House of Representatives.
This means the Speaker can lose the position if they cease to be a member of the House of Representatives or if they resign from the position. The Speaker can also lose their position if the members of the House of Representatives decide to vote them out. The longest-serving Speaker was John McLeay who served as Speaker for 10 years from 1956 - 1966!