Is it safe to take medications while pregnant?

Depends. It depends on the medication. Discuss the medication with your OB and decide if the benefits out weigh any risks.
Yes. Many medications are safe during pregnancy but there are huge differences in safety with different medications. If you normally take medicines, talk to your doctor before you get pregnant to see which are safe. If you don't need to take something, like cold medicines, it's better to avoid them.