Criminal Law Questions? Ask a Criminal Lawyer.
I will try and help. The short answer is no. It is not illegal to wonder about the gender of a person or to ask/comment about it. This is not exactly the type of comment we generally like from teachers (and I only have your side), but based on what you have offered, you do not have a cause of action.
I hope this helps.