Is it safe to take heparin while pregnant?

Yes. A blood thinner like Heparin is required to treat some conditions like blood clots, which can be life-threatening. It can increase bleeding so it is very important that women with these conditions see an expert (eg, perinatologist or hematologist), have an accurate diagnosis and discussion of risks and benefits of anticoagulation to mom & baby, have monitoring of their condition through pregnancy.
Yes. Heparin is used sometimes in pregnancy for very specific medical complications of pregnancy like antiphopholipid antibody syndrome and other disorders related to blood clotting. It is safe to use for these conditions and will need to be monitored by your doctor. It can be given as an injection or also as a continuous pump placed under the skin.