Eh, it's not really a big deal.
This isn't high school - your responsibility as a student is to do the work required to pass. End of story. A professor cannot make demands of you to change your appearance.. especially if you have long hair.
Tell him to get over it. He can't legally fail you because you have long hair.
Besides, long hair matters none in a professional environment despite what many will say. If an employer has the nerve to make such an asinine request, then chances are they'll have a shitload of other equally asinine "rules" that you have to follow for some reason.
Your happiness in your career should come first and foremost, unless, of course, you're just a drone that works JUST for the paycheck.
If you do your job and do it well, that's all that matters, but for some reason people like to think otherwise.
To me, an employer, professor.. you name it, needs to give respect in order to get respect. Making stupid requests like that gets you nowhere fast.
...and sorry to break it to ya smooth, but you are NOT paying for their education (if you care to show otherwise, be my guest). That would be like someone saying to a police officer, "I pay your salary!" Yeah yeah.. no you're not. Until the students get free college education and aren't paying shitloads of $$ to attend, any school/professor is out of line in matters such as this.
[edit]
Let's say, for the sake of argument, that you were paying for his tution... are you really THAT ignorant to let LONG HAIR bother you?