It looks like you are suffering from a muscle spasm in the rib cage
due to the cough, the muscle laxity of pregnancy
adding to this. What you need is a muscle relaxant
, an oral medication or a local application, under guidance of your obstetrician. You may also use cough suppressants if you have a dry cough
with proper precautions. Contact your doctor for further advice. Take care.