Sore or stiff neck in the mornings is a very common problem. Most of the time it is caused by too much flexion of the neck when sleeping, which leads to strain of the muscles that run up the two sides of the spine in the neck, which are known as the paraspinal muscles.
Cases of paraspinal muscle tenderness can be treated with standard anti inflammatory medications, which is what you are doing by taking ibuprofen. However, it can also be helpful to perform some neck stretching and strengthening exercises. You should make an appointment with your primary care doctor
, who can describe to you how to perform these exercises.
Also, in order to prevent further episodes of neck pain on awakening, it is probably necessary to work on your posture while sleeping. The biggest factor is usually sleeping with too many pillows. Reducing yourself to just one pillow and sleeping on your side with your knees slightly bent so that your neck is in a neutral position is probably best.
Set up a visit with your primary care doctor as soon as you can. They can talk to you about this issue in greater detail, and also followup with you to make sure things are getting better.