Talk with your doctor, nurse, or a lactation consultant about the risk of passing the STI to your baby while breastfeeding. If you have chlamydia or gonorrhea, you can keep breastfeeding. If you have syphilis or herpes, you can keep breastfeeding as long as the sores are covered. Syphilis and herpes are spread through contact with sores and can be dangerous to your newborn. If you have sores on your nipple or areola, stop breastfeeding on that breast. Pump or hand express your milk from that breast until the sore clears. Pumping will help keep up your milk supply and prevent your breast from getting engorged or overly full. You can store your milk to give to your baby in a bottle for another feeding. But if parts of your breast pump that contact the milk also touch the sore(s) while pumping, you should throw the milk away.
If you are being treated for an STI, ask your doctor about the possible effects of the drug on your breastfeeding baby. Most treatments for STIs are safe to use while breastfeeding.
This answer is based on source information from the National Women's Health Information Center.