Sir is an honorific address used in a number of situations in many anglophone cultures. The term can be used as a formal prefix, especially in the Commonwealth, for males who have been given certain honours or titles (such as knights and baronets), where usage is strictly governed by law and custom.
The term is also commonly used as a respectful way to address a man, usually of superior social status or holding a commissioned military rank. Equivalent terms of address to females are 'ma'am' or 'madam' in most cases, or in the case of a young woman, girl, or unmarried woman who prefers to be addressed as such, 'miss'. The equivalent term for a knighted woman or baronetess is Dame, or 'Lady' for the wife of a knight or baronet.
'Sir' derives from the Middle French honorific title sire. Sire developed alongside the word seigneur, also used to refer to a feudal lord. Both derived from the Vulgar Latin senior, sire comes from the nominative case declension senior and seigneur, the accusative case declension seniōrem.
The form 'Sir' is first documented in English in 1297, as title of honour of a knight, and latterly a baronet, being a variant of sire, which was already used in English since at least c.1205 as a title placed before a name and denoting knighthood, and to address the (male) Sovereign since c.1225, with additional general senses of 'father, male parent' is from c.1250, and 'important elderly man' from 1362.
The prefix is used with the holder's given name or full name, but never with the surname alone. For example, whilst Sir Alexander and Sir Alexander Fleming would be correct, Sir Fleming would not.