What causes pain behind the neck?

Muscles. The neck is held up by spinal bones, ligaments , tendons and muscles. Likely you have a tension type muscular skeletal dysfunction.
This is treated by OTC meds like Advil, Tylenol. Also good for headache.
Massage, chiropractic manipulation can also relax the muscles and realign the natural curve in your neck.
See a doctor if not better in 24 hours for examination.