Animals can greatly increase their fitness by choosing oviposition sites free from damaging substances such as the heavy metal cadmium (Cd). Previous research has shown that Drosophila melanogaster reared on uncontaminated media lay fewer eggs on substrates containing Cd. In this study, we examined the effects of prior exposure to Cd on oviposition site preference. We tested flies that had been exposed to Cd continuously from egg to adult, only during pre-adult stages, or for the 4 days of adulthood prior to testing. We found that flies avoid laying eggs on Cd-contaminated medium and also that flies exposed to Cd as adults laid significantly fewer eggs than controls never exposed to Cd. We did not observe consistent changes in oviposition as a result of pre-adult exposure alone. Our results suggest that the presence of cadmium in the environment, even at low doses and for short periods of time during adulthood, can harm the fitness of Drosophila melanogaster.