There is a pill to prevent HIV? Yes!
PrEP is a once-a-day pill for people who do not have HIV and want added protection. When taken as prescribed before exposure, PrEP is highly effective in protecting against getting HIV. Condoms can be used to protect against other common STDs.
PEP, short for post-exposure prophylaxis, is a different medication intended for limited emergency situations only. It also requires a prescription and must be taken within 72 hours after a possible exposure to HIV.