Condoms and femidoms cannot reliably prevent the transmission of sexually transmitted diseases but they do reduce the risk of infection.
Most sexually transmitted diseases are easy to treat. People who have sex with changing partners should get examined on a regular basis to identify an infection early and not pass it on to others.
In addition, you should not touch any skin lesions (cuts), wounds or sores.
There are vaccinations that protect against hepatitis A and B as well as HPV.
When injecting drugs, you should only use your own injecting equipment (syringe and needle) and accessories and not pass them to others.