Developmental morphine (MOR) exposure (DME) detrimentally affects the cognitive abilities of the next generation. It is shown that postnatal rearing environments and prenatal conditions effectively impact memory. The present study investigated the effects of DME, postweaning rearing, and sex on spatial learning and memory. At molecular level, we evaluated mRNA levels of brain-derived neurotrophic factor, cyclic AMP response element-binding protein (CREB), μ-opioid receptor, and ΔFosB in the hippocampus of male offspring. Female Wistar rats were treated with escalating doses of MOR or saline before mating, gestation, and lactation. On Postnatal Day 22, the male and female pups were divided into 12 groups and raised for 2 months under different conditions: standard, isolated (ISO), or enriched environment. Afterward, the Morris water maze task measured spatial learning and reference memory; rats were then sacrificed to assess hippocampus gene expressions. Results indicated the DME and isolated rearing increased latency to find the hidden platform in male offspring. DME was insignificant in female offspring, whereas rearing environments significantly altered escape latency in both sexes. We also found that the enriched environment upregulated the brain-derived neurotrophic factor mRNA in both saline and MOR groups, whereas it downregulated the mRNA levels of CREB1, μ-opioid receptor, and ΔFosB in the MOR group. In addition, the DME enhanced CREB1, μ-opioid receptor, and ΔFosB gene expression in the MOR + isolated group. Our findings signified the effects of DME, rearing environment, and sex on the spatial learning abilities of offspring. Also, we showed that DME and rearing conditions could manipulate hippocampal neurochemistry.