The first and best line of defense is to use a latex barrier whenever you have sex (if you have a latex allergy, use polyurethane instead). That means using a condom on the penis or on a sex toy; latex gloves on your hands; and when engaging in oral sex, dental dams or plastic wrap to cover the anus or vagina.
Knowing your own status is the only way to approach the next point honestly.
Safer sex also involves talking with your partner, discussing activities and risks and making educated choices together. Of course, sex raises a number of other questions. Do you trust your partner? How do you get a guy to use a condom if he refuses to do so? What if you are suspicious that your partner is not being monogamous?
Total abstinence is the only 100% effective safe sex method; it's just not that realistic for most people. Next in line is a long-term monogamous relationship in which both partners know their status to be negative for STDs (itself requiring testing and honest communication), and both stay true to the monogamous ideal.