I once had a pretty bad cough which lasted like.. forever. I just let the coughs go on and on until one day I coughed too hard and suddenly felt some abdominal pains. It was a sharp pain right between my ribs, where the sternum is, and I can only feel the pain WHEN I cough.
I asked my father about it and he, being the regular hypochondriac he is, told me that it was just a strained muscle. It is something like when you accidentally pull a muscle from moving too quickly or when you exerted too much force.
After that, I refrained from letting the coughs fly out of my lungs and started taking drowsy cough medicine which didn't help with the pain but kept the coughing down. My pain went away a week after the first sign of pain. What? I'm a lousy healer.
Hopefully that is the pain that you are referring to, because breaking a rib is really terrible. Either way, it is safer to go see a doctor about the pain. Best wishes.