Ampicillin is often used in gynecology to treat infections such as pelvic inflammatory disease (PID), endometritis, and infections related to gynecological surgeries. It can also be prescribed for urinary tract infections (UTIs) and certain sexually transmitted infections (STIs).