UTI question

Can I have sex while taking medication to treat a urinary tract infection?