This is a loaded question and, honestly, this needs to be answered with a thorough consultation from a corrective exercise specialist.
A corrective exercise specialist will look at what is causing the pain and what muscular imbalances could be causing the issue. After evaluating the overactive and under-active muscles, the fitness professional will be able to implement a flexibility strategy for the tight muscles and an activation/strengthening strategy for the weak muscles.
Generally, pain in the neck and shoulders will come from tightness in the upper traps, lats, pecs and teres major. Weak muscles will generally be the lower and mid traps, rear deltoids and rotator cuff, as well as the rhomboids.
Now, this is without evaluating and a general response, but I would suggest a foam rolling and stretching strategy for your upper traps, pecs, lats and teres major with an activation of the mid and lower traps, rear deltoids, rotator cuff and rhomboids.
Many times posture and positioning of the head and strength of the core will also lead to pain in those areas. Even if you do not get evaluated by a corrective exercise specialist, tucking your chin (which forces your head backwards), drawing in your abs, activating your glutes and maintaining this position during exercise and activity, at the bare minimum, will put you in a better postural position.