Hello there. There might be few reasons causing such pain. In shoulder & neck.
Your sleeping position, your continuous sitting position if you are or were working earlier, any history of injury to neck or shoulder, lifting weights as in workouts.
Next Steps
Kindly get an X-ray for your neck as there seems a possibility of cervical spondylitis with muscle spasm. You can take painkillers or muscle relaxants as prescribed by an orthopedic or a physician. you can aslo visit a Physiotherapist to reduce the stiffness & pain in the form of taking heat / electrotherapy. traction can help too. alongwith exercises of neck & shoulder in stretching & strengthening form.
Health Tips
Try to Use a firm pillow will medium thickness or a Towel roll under your Neck while sleeping. Keep stretching to avoid further pain & stiffness. You can start with hot packs at home.