First, write down all the points and reasons you can think of why listing to music is good and why your boss is wrong.
You want lots and lots of mildly convincing points, a good selection of generally convincing points and one or two amazingly convincing points
Step one,
Write a formal complaint letter addressed to your bosses boss using all the generally convincing and amazingly convincing points and asking for your bosses boss to respond. Explain why your boss is wrong and his decision will cost the company money, include any official studies done on listening to music helping people to perform tasks. You can relate it to music that doctors use during surgery, that sort of thing.Your boss is probably assuming that the sort of music you're listening to is heavy metal or something equally as distracting so use this assumption against him. Say in the report that you're listening to classical or something that makes logical sense for helping you to program and you cant understand why your boss thinks this is bad.
Don't send it yet.
Step two.
Go and see your boss and explain why you need to listen to music using your mildly convincing points. Try and convince him to change his mind.
Once you've finished talking to your boss he's either going to decide he was wrong and renege or decide the rule stands, or try to stall for time and hope you go away. If he stalls just go back to him in 2 days and continue the talk.
Step three
When you get the answer of "No" whip out the letter from your back pocket and tell your boss you're laying a formal complaint and ask him to pass the letter on to his boss. Tell your boss he can read it if he wants before passing it on. Then walk out of the room leaving your boss with the surprised expression on his face.
What will happen...
Your boss now has two options, he can give your report to his boss, which makes him look like an idiot or he can change his mind on the rule to make you withdraw the complaint. Either way its probably good for your case. If he doesnt change his mind about the rule and you dont hear anything directly from your bosses boss he probably didnt pass on the report and you can get him in some serious trouble for not passing on a formal complaint to who it was addressed to.