Prescription narcotics like Vicodin and benzodiazepines like Xanax are not likely to cause birth defects, but doctors do try to avoid prescribing them during pregnancy unless it's absolutely necessary. That's because taking these medications for an extended period of time can cause you to build up a tolerance to them. As you require higher or more frequent doses to cope with your conditions, your baby can actually become addicted to them.
It's up to your doctor to decide whether these medications are safe for you. To minimize the effects on your baby, you should be on the lowest doses that your doctor deems appropriate. Your doctor may also advise that you slowly wean yourself from the meds as your due date approaches to make your baby's withdrawal easier. Keep in mind that these are very powerful drugs and you may need help in cutting back. When your baby's born, be sure that the pediatricians on call know that you've been taking prescription narcotics or benzodiazepines, so that they can better assess your baby's health.