I find this interesting.
I have made a point, when DS has said similar, that it's not OK. It's sexist.
Its come from school. And it's interesting where its come from. It's come from parents who say it. And don't see anything wrong with it.
Part of the problem here, is precisely because YOU don't see the problem and are questioning the punishment. It's infuriating. Especially when you end up on the receiving end of it from a young child. It is teaching disrespect to girls and women is ok. I absolutely won't tolerate it, and I don't have a high opinion of parents who do.
Girls suffer massively with confidence, in ways boys don’t. Because they are told from an early age that they come second to boys. And they are physically weaker. This isn't ok.
YOU are part of the problem here.
Girls and boys have individual strengths and weaknesses. Normalising the idea that girls are inferior sets up certain behaviour patterns. It's the root of toxic masculinity, which also isn't good for boys. The physical differences at that age are minimal too. Before puberty it doesn't exist.
It's a put down to bully. And it's sexist to boot.