Upper back pain or thoracic area pain is sometimes caused by trigger points or muscle knots. Trigger points are basically when a specific area on a muscle gets irritated and tightens up into a ball or knot.
This video contains some stretches and exercises that may help relieve trigger points or muscle knots in the upper back.
Stretching the Rhomboid muscles in the upper back is a great way to reduce the pain. These stretches can be done in long sitting or regular sitting. After stretching the rhomboid muscles, they can be strengthened with scapular squeezes (shoulder squeezes).
Next are some stretches for the upper back or thoracic area. Thoracic rotations and thoracic sidebends are a great way to help loosen up the muscles to decrease trigger points.
Finally, if the stretches are too difficult or maybe you are on precautions to not do those movements, a ball can be used to put pressure on the trigger points directly. A little pressure goes a long way, but too much could irritate it more.