An oath of allegiance is an oath whereby a subject or citizen acknowledges a duty of allegiance and swears loyalty to a monarch or a country. In modern republics, oaths are sworn to the country in general, or to the country's constitution. For example, officials in the United States, take an oath of office that includes swearing allegiance to the United States Constitution. However, typically in a constitutional monarchy, such as in the United Kingdom, Australia, and other Commonwealth realms, oaths are sworn to the monarch. Armed forces typically require a military oath.
In feudal times, a person would also swear allegiance to their feudal superiors. To this day the oath sworn by freemen of the City of London contains an oath of obedience to the Lord Mayor of the City of London.