There are two antibiotics, commonly used to treat urinary tract infections (UTI) in pregnancy, sulfa drugs (brand names including Bactrim) and urinary germicides called nitrofurantoins (brand names including Furadantin and Macrobid). They have recently been linked to some forms of birth defects including anencephaly (a fatal brain defect), cleft palate and heart defects. Though it is currently unclear whether or not the birth defects are caused by the medications in question. There are others that are still considered to be safer.
It is important to treat urinary tract infections in pregnancy to ward off preterm labor. The drugs used are rated by the FDA but not the safest grading, an A. But they have been used for years without studies as is common with most medications in pregnancy.
Related:
Source
Krista S. Crider; Mario A. Cleves; Jennita Reefhuis; Robert J. Berry; Charlotte A. Hobbs; Dale J. Hu. Antibacterial Medication Use During Pregnancy and Risk of Birth Defects: National Birth Defects Prevention Study. Arch Pediatr Adolesc Med. 2009;163(11):978-985.

