A headmaster is the principal of a private school. Your prep school headmaster might have also taught your favorite English class.
The head of a school, especially if the school is in Britain or is private or a boarding school, is called a headmaster. The headmaster is often in charge of discipline as well as the running of the school. It's common these days to use the term head teacher rather than headmaster, since it includes both male and female principals. The word headmaster has been around since the 1570's.