In the United Kingdom, persons who become naturalised citizens swear allegiance to the monarch and their lawful heirs and successors. Non-religious people may affirm instead of swearing an oath. Judges, military personnel, public notaries, and clergy of the Church of England, do likewise on taking office or being admitted to their respective status. Holders of various important offices take the oath as soon as possible after assuming office, and members of either house of Parliament and the Scottish Parliament and Welsh Assembly must do so before they can take their seats.
Some people, including police officers in England and Wales, and members of the Privy Council who have a more elaborate oath, swear only to the current monarch. Presumably they are re-sworn when there is a new monarch.
Native-born citizens who don't become any of the kinds of public servant listed above normally go through their entire lives without taking any oath of allegiance, as I have. The idea of schoolchildren taking it at frequent intervals is one of the things that seem very strange about the USA to the British.