Therefore I fail to see any reason why a trans girl shouldn’t be head girl.
The reason why we have head girls as well as head boys is to ensure equal representation of male and female children. If two male children represent the school, there is no equal representation.
As for the teacher - I would like to see the exact wording of her remarks and those of the pupils. Generally speaking, in my view no teacher should be singling out any pupil in this manner, no matter what the occasion. The teacher could have had a conversation about equal representation of the sexes not being ensured if two male or two female individuals are chosen in a different manner.
It still would most likely have been obvious what prompted the conversation, but by keeping it general, the teacher could have easily stopped all remarks against the pupil in question as being inappropriate.
Teachers have a duty of care towards all children and on the face of that article, she failed in that duty.