After an infection (which are mostly viral), it’s very common for children to continue to cough for a long time, sometimes weeks or even months. It’s quite irritating and worrying for parents.
Cough lasting more than 2 weeks in an adult is quite worrying and has to be investigated to rule out Cancer etc. Luckily, Lung cancer is not common in children, still you should see a doctor if the cough is not going, specially if associated with fever, loss of appetite, night sweats, weight loss, rash etc.
If it’s after a viral infection, like ‘Bronchiolitis’, it’s usually body’s response to open up the lungs and need not be worrying as long as the child is ‘otherwise’ well ! With infections, there is excess mucous production along with swelling of airways, leading to ‘alveolar collapse’, meaning the small air sacs in lungs deflate. Once the infection is cleared, the body then starts to recover and cough is one mechanism by which lungs regain their normal structure. Sometimes, chest physiotherapists, deliberately make patients cough, if they are too weak to cough, like in Intensive Care units!
So all cough is not BAD!