In front of the rest of the class and a class that you are PAYING FOR? Darn right it was inappropriate and unprofessional. I can not imagine that question being asked by a professor that you don't know. I am curious as to her tone of voice when she asked that question too. BTW, what course was it?
Too bad the question caught you off guard otherwise you could have responded by asking her why she chose her particular hairstyle and if she really liked that look.
Hell Yeah I like it, and I'll let you rub on it for some bonus points!