Dairy (any dairy) can cause phlegm, so if he has had flu, it could just be the cough and phlegm lingering - I know that when I have a cold, I still cough for a week or 2 after the actual cold / flu has cleared up.
So first cut out any dairy like cheese, yoghurt and even if you are feeding purity, try give him the dairy free for a while.
Babies also cannot really cough up phlegm, so if it is really bad, perhaps take him to physio to get it all removed, and take it from there, before panicing about allergies.
If it was a reaction to the formula, it would generally affected him pretty much within a day or 2 of starting to use it.
As for not wanting his milk, it could be the flu could have affected his ears, he could be teething, so his mouth is sore (this can also cause phlegm).