Yes, it's probably parasites in your lungs. Worm larvae go there to molt. I have gone through the lung phase many times, first a cough, then phlegm, then it goes away for a few weeks. When fighting them, the lung phase seems to be more frequently, like they are scrambling to repopulate as they are dying. Hope that makes sense.
I also have odd headaches when killing worms. They come and go, like annoying pain for 20 minutes, then it's gone, and back in an hour but in a different location. Totally the opposite of a "normal" headache.