That pain is caused by a pinched muscle in your back. There really isn't much else to pick from for that pain. You may have got it started when you did the coughing and it finished up by some other way, and there are so many different ways that could happen that anything is pure speculation. When pinched, some muscles refer pain so you don't feel where it is pinched, sometimes the muscles tighten up so that it can feel hard to take a breath, and they are all caused by a pinched muscle in the back. Once you release those muscles the pain will be gone. Here's how to release those muscles:
Back:
(do from a sitting position)
Place your left hand on your left leg next to your body. Place your right hand over your left shoulder and find the muscles next to your spine and press on them and hold. After 30 seconds slowly lower your body forward and to the outside of your left leg, keeping your left arm fairly straight as you do. When you reach your lap remain there for another 10 seconds, release the pressure but rest there for another 30 seconds. Then reverse your hand positions and do your right side.