The simple answer is to stop all unnecessary medications before trying to get pregnant, but of course, this is not always feasible.
Some medications that you absolutely must avoid because they may harm the fetus include isotretinoin, better known as Accutane (used for acne), Coumadin (an anticoagulant used to prevent blood clotting), tetracycline (for acne or infections), valproic acid (for epilepsy), ACE inhibitors (for hypertension), injectable or preventive medications such as Imitrex and propranolol (for migraines), antimalarial drugs such as Plaquenil, or high doses of steroids such as cortisone and prednisone. Be sure to speak with your doctor before stopping any prescription medication.
Many pain-relieving medications are safe in small amounts. However, some nonsteroidal anti-inflammatory drugs (NSAIDs), or any medication containing ibuprofen, may affect ovulating and the endometrium.
The best advice is to talk with your doctor before taking any medication. For many drugs, there are equally safe alternatives for pregnant women. For example, if you need an anticoagulant for deep vein thrombosis, heparin is safe because it does not cross the placenta. Discuss these issues with your obstetrician before attempting to conceive.