Is it safe to continue breastfeeding if mother has a bacterial or viral infection or should prepumped milk be used instead?
It depends. If you get a bacterial infection and have to be treated with an antibiotic, the doctor usually chooses one that will not prevent you from breastfeeding. With a viral infection you can breastfeed. It is recommended to get flu shots during pregnancy and in the postpartum period to prevent infecting the newborn. Discuss the antibiotic selection with your doctor to make sure it is safe.
What to do if I am a mother of 5month old baby, I am having viral infection, I don't want my baby to get it from me, does breastfeeding spread my infection to the baby?
Very unlikely. With some exceptions e.g., HIV or hepatitis b, most of viral infections are not transmitted to infants via breast milk.