Yes you should always spit out phlegm when you can do so.
Never swallow your phlegm because your phlegm contains bacteria that your body is wanting to get rid of and needing to get rid of.
When you swallow your phlegm that bacteria and germs gets back into your body which makes you sicker and can prolong your illness.
Always spit the phlegm out either onto the ground or into a toilet, sink etc and make sure to wash the phlegm away.
Phlegm although will not harm you if you do swallow it is not good to swallow and should always be spit out when you can do so in a sanitary and non disgusting manner.