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.
When injecting drugs, you should only use your own syringes and needles and not pass yours to others.