Head Master is the Head of an Institute.We usually write The Principal in upper case.
Why is the word head master written in a lower case.
Positions in institutions (organizations, institutes etc.) are not capitalized unless the person's name is used.
The head of an institute is not a formal term. An institute usually has a director: In June, Director Smith traveled to Hungary.
Headmasters are the top person in a school. If the name of the headmaster is given, it would be capitalized: Headmaster Smith. In June, Headmaster Smith left the school.
The same goes for the principal of a school. Of course, a particular school may decide to capitalize the Principal, but that's up to the school but is not a usual way of writing it in a report or journalism.
Head Master (or Headmaster) is written with initial capitals when it is a specific person's job title.
Welcome from the Head Master
Rugby’s greatest Head Master, Dr Thomas Arnold, knew that education is all about transforming lives
https://www.rugbyschool.co.uk/about/welcome-from-the-head-master/
Alastair Land, Head Master, read Natural Sciences at Trinity College, Cambridge, ... [At Eton] he became a Deputy House Master ... Alastair was Deputy Head Master at Harrow for three years from 2012, before he moved to Repton as Headmaster. He returned to Harrow as Head Master in April 2019.
https://www.harrowschool.org.uk/from-the-head-master
About the Headmaster
https://www.bromsgrove-school.co.uk/abouttheheadmaster
Note that Rugby and Harrow use Head Master but Repton and Bromsgrove use Headmaster and the original institution's term is retained. A few schools use High Master or High Mistress.
The same applies to kings and queens in general, but the King of Norway or the Queen of England, and the principal or the warden of a college but the Principal of St Margaret's College and the Warden of Shrewsbury College.
In British English we would not say Director Smith or Head Master Smith. They are job titles not personal titles or military ranks (like Dr. Smith, Revd. Jones, Lord Snooty or Capt. Kirk).
In Ramsay's Kitchen Nightmares USA, Gordon Ramsay is always addressed as Chef Ramsay. In the British series he's addressed as Gordon, or Chef.