You can get a UTI from sex, but a UTI is not considered a sexually transmitted infection (STI). Sex can increase the risk because it may allow bacteria from the vaginal area and perineum to enter the urethra.
A UTI is usually caused by bacteria from the skin or intestines that enter the urethra. UTIs are more common in sexually active women and also tend to happen more often during menopause. Other risk factors include spermicide use, poor hygiene, and abnormalities in the urinary tract.