I've had the same problem for 12 years and finally got diagnosed this year. Although it's my neck that goes into spasm it's actually referred from the trapesius muscle which goes across the back of your shoulder.
It's apparently due to a combination of RSI from being at a PC all day and chatting on AB all night (!) and stress. I'm having acupuncture on the NHS with a physio, who also told me to get weekly massages (which I can't afford - but if you can get a partner/parent/friend to give you a rub it really helps).
My lifesavers have been seeing a chiropractor and doing Pilates. When it completely seizes up (and I can so sympathise with the pain - it really is excruciating) I go to the chiro, who has me back up on my feet within 20 minutes and when it is okay I try to do Pilates as often as possible using a Lynne Robinson DVD at home - it really does loosen up your back and neck and helps prevent the problem recurring.
Most important thing is, when it happens, the temptation is to stay in bed or do no exercise, but trying to keep it moving even though it hurts is the best thing to get the spasms to stop. A trip to your GP is probably a good idea, but, as I've found out, they will give you anti-inflammatories and do little else. Pester them for a physio referal if the problem continues and I hope you feel better soon.