There are very few cases where you would need to stop breastfeeding if you have an infection. It makes far more sense to continue breastfeeding as this will actually help protect your baby. By the time you have developed any symptoms of an infection you have already been breastfeeding for several days, by continuing to nurse you will give your baby the best protection against this infection. Your breastmilk will contain special antibodies that will help prevent your baby from getting sick.
Even in cases of breast infections, such as mastitis it is far better to continue breast feeding. If the infected nipple is too sore you can use the other side for a day or two. The infection will heal far more quickly by continuing to breastfeed. If you do have an infection that you are concerned about you should always visit your G.P. who will clarify whether you can continue breastfeeding.