It is generally safe to masturbate while you are being treated for bacterial STDs, such as chlamydia, gonorrhea, and trichomoniasis, which are being treated systemically with antibiotics. It's also pretty safe to masturbate with sexually associated infections such as bacterial vaginosis and yeast infections, even if you're using local treatment. However, with any of these diseases, if you masturbate with sex toys or other objects you should be certain to cover them with condoms and/or disinfect them thoroughly between masturbation sessions. If you don't, those same toys could end up harboring fomites that might infect you at a later date.
On the other hand, if you are infected with a treatable STD that spreads by skin to skin contact, you will want to be more cautious about masturbating. It is possible to spread diseases such as molloscum around your body through a process known as auto-inoculation. In other words, if you touch a sore, you can move infectious material to another part of your skin and start to get sores there. Therefore, as much as possible, you should try to avoid touching active sores or disease lesions during masturbation. As it is also possible to end up with infectious material trapped under your nails, masturbation or mutual masturbation with gloved hands is always a good option.
As for diseases that can be treated, but not cured, such as herpes and HIV, masturbation safety varies by disease. It is possible to auto-inoculate yourself with herpes, so you should either avoid masturbating during an outbreak or be careful not to touch your sores. However, you can not re-infect yourself with HIV, so if you masturbate in a shared environment, you should just be certain to clean up after a session to avoid the risk of exposing anyone you live/work/play with to potentially infectious biological fluids such as semen or vaginal secretions.
Making Masturbation Safer
Since people don't always know when they are infected with an STD, here are some things to keep in mind that can make masturbation safer without making it less fun.
- Wash your hands before and after masturbation to avoid transferring bacteria or other pathogens to or from your genitals.
- Avoid touching your eyes while you are masturbating. The eyes are mucosal surfaces, just like the genital region, which means they are susceptible to a number of STDs, and ocular STD infections can be extremely nasty. If untreated, they can even lead to blindness.
- Always clean any sex toys you use thoroughly after use.
- Never share sex toys without covering them with condoms or disinfecting them thoroughly.
- If you find pimples, sores, or other strange bumps while masturbating, immediately go and wash your hands, and then try to avoid touching them. Although they may not be STD related, you do not want to end up moving bacteria around your genitals if you can avoid it. Furthermore, you may want to consider seeing your doctor or visiting an STD clinic for screening, just to make sure that you do not have an infection.