It can mean either depending on context. If it's about a school it's headteacher, in a company or organisation it will mean Head.
There are words for headmaster and headmistress but they are being replaced by the gender neutral pennaeth.
Thank you for the explanation, but in the sentence above you don't know the context, so the answer "headmaster" shouldn't be marked as wrong. If I see this sentence again, I will report this.
I've checked it out and as it is clearly in the education unit it should also be headteacher, so that's added now, thanks for the comment.