Aside from the viability of long hair in the workplace, there is the main issue: how much power does you professor have over you? He thinks, quite a lot. As an older man who went back to school lately, I must say that many college professors seem to enjoy having authority over their students. A significant minority push it too far.
You state it correctly: "I'm paying for this." That's right, you're the customer. In the real world, you should be well-treated. But the university world doesn't work like that; it's a hierarchy, with the students at the bottom. And some professors and instructors take advantage of that prerogative to force you to do things which are improper. Because they can, because nobody stops them, because they hold your grade over your head and most students will bow to that. And because that's the kind of people they are.
Seen from my older point of view, with a lot of experience in the world of work, I see many college professors as second-raters. Their job is to pass knowledge, and a lot of them do a piss-poor job at it and don't always seem to take it very seriously. At least at UC Santa Cruz.
So you have three choices: 1) give in; 2) have another conversation with the instructor, explain your reasoning and why you think he's wrong, and how you'll have to go to the dean (do it in writing if you think that's best); then give him a chance to respond, as maybe he'll see daylight; 3) Go to the dean, either instead of or after choice 2.
Going to the dean will probably get you the decision you want; of course there is always the chance that your prof may later grade you unfairly. It's childish and unprofessional, but such behavior is tolerated among college instructors. If that happens, you have to go back to the dean again. But -- you may not be the first person to go to the dean about this guy, if he's being this outrageous. And if he's just a lecturer, a part-timer, his place in the educational hierarchy is almost as low as yours, and he may snap to without even a squeak.
His opinion on long hair may have validity, but he's forcing you to change your appearance and lifestyle to pass his class. And he does not have the authority to do that. Although he thinks he does.
Personally, I had a career in tech writing for 20 years and almost always had long hair. Made manager a couple of times, though I didn't really want it. But then tech writers are supposed to be weird and unbusinesslike, so maybe it didn't matter. And they didn't let us out much, either.
To be fair, everybody going into the field had hair no longer than an inch above the collar, especially for sales and marketing-related stuff.