Simply put and to be as safe as possible: vaccinations should not be given to pregnant animals, but most vaccinations are safe for nursing animals.
There are some fine points to consider, however, as not all vaccines are created equal. The time since conception (how far into the gestation period the animal is) also relates to the safety of vaccines and pregnant animals.
Pregnancy in Cats and Dogs
Vaccinating While Pregnant
The first half of the pregnancy is the most vulnerable time for fetal development. Vaccines that are modified live (versus killed) are not considered safe at any time of the pregnancy. Killed vaccines, such as rabies vaccines, may be given during pregnancy (especially during the latter half of gestation) but are not recommended.
There may be situations where vaccination may be advised to protect the mother's health. Your veterinarian will be able to assist and guide you in that choice, if necessary.
How and When Vaccines Work
Vaccines protect animals by stimulating the body to produce antibodies to fight off disease. Vaccines take approximately one week to one month to effectively stimulate the body and produce antibodies, depending on the animals age and previous vaccine history.
Antibodies are passed through the mother's milk. A well-vaccinated mother will provide protection to her newborns through the colostrum (first milk). However, the newborn animals are only able to absorb these antibodies through their intestine for a few hours after birth.
Vaccinating While Nursing
While vaccinating a nursing mother animal with a killed vaccine won't hurt the babies; it won't protect them either since the vaccine takes at least a week to stimulate antibody production and the window for absorption in the newborns is much shorter than that.
Planning Ahead for Best Protection
The safest way to vaccinate animals and offer optimal protection for the offspring is to vaccinate the mother a few weeks before she is bred. This will ensure that the antibody levels will be at good levels (barring any unforeseen health problem of the mother) and offer the best chance for antibody absorption by the newborns.