When you cough or exert yourself the muscles contract. If it persists you need to see a DR. You probably pulled a muscle and it is healing. If it is red, swollen or has a change in color or temperature see the DR. If you think it is serious all see the DR.
I would first call your doctor to see if he would like you to come in. However, most muscle pain is made worse by straining. Try taking some ibuprofen, such as Advil, to reduce the pain.
If you exercise your thigh a lot, have been bicycling lately or put any strenous activity on your thighs will result to muscle pain. Coughing or straining contributes in aggraviating muscle pain.