Mothers with a CYP2D6 ultrarapid metabolizer phenotype may expose their infants to risk of adverse events when taking codeine while breastfeeding, by producing more of the active metabolite, morphine. Pharmacogenetic testing may be a valuable tool to identify such mothers, but testing can be costly. The objective of the study was to determine the incremental costs of genotyping to avert neonatal adverse events during maternal pharmacotherapy. A cost-effectiveness analysis, using a decision model, was performed with a hypothetical cohort of prenatal subjects. Parameter estimates, costs and ranges for sensitivity analyses were ascertained from the literature and expert opinion. Sensitivity analyses were conducted to assess the robustness of the results. Probabilistic sensitivity analysis revealed an incremental cost-effectiveness (ICER) of $10 433 (Canadian dollars) for genotyping compared to no genotyping per adverse event averted. Results were sensitive to hospital admission costs. The ICER was lower when evaluating only subjects having caesarean deliveries or those from ethnic populations known to have a high prevalence of ultra-rapid metabolizers. Although genotyping to guide pharmacotherapy was not cost saving, the cost to avert an infant adverse event may represent good value for money in specific populations. With a growing demand for personalized medicine, these findings are relevant for decision makers, clinicians and patients.