Post-exposure prophylaxis (PEP) is a preventive medical treatment started immediately after exposure to a pathogen, such as HIV, to prevent infection. It is most effective when initiated as soon as possible, typically within 72 hours of exposure, and involves a course of antiretroviral medications taken for 28 days.