Hello and welcome
I have read your query with diligence. There are few possibilities that can cause the pain:
1. Muscular spasm: due to prolonged coughing the muscular spasm is quite often. Try analgesic
and anti-inflammatory drugs with hot fermentation at the site.
2. Bronchial Pneumonia: The cough with expectorant when occur more than 2 weeks can cause a patch of pneumonia.
3. Infection in the lungs
Get your chest X-ray done any rule out any kind of infection in it. Consult your treating doctor for further management.