You should see your doctor and request 2 tests:
1) spirometry, a simple breathing test; and
2) a chest x-ray.
If the cough persists for more than 3 months, you and your doctor should do further testing to find the cause. What you describe, having a sporadic capacity could be a sign of asthma. It is a disease that waxes and wanes and that could be what you are experiencing.