The mechanistic basis for how genetic variants cause differences in phenotypic traits is often elusive. We identified a quantitative trait locus in Caenorhabditis elegans that affects three seemingly unrelated phenotypic traits: lifetime fecundity, adult body size, and susceptibility to the human pathogen Staphyloccus aureus. We found a QTL for all three traits arises from variation in the neuropeptide receptor gene npr-1. Moreover, we found that variation in npr-1 is also responsible for differences in 247 gene expression traits. Variation in npr-1 is known to determine whether animals disperse throughout a bacterial lawn or aggregate at the edges of the lawn. We found that the allele that leads to aggregation is associated with reduced growth and reproductive output. The altered gene expression pattern caused by this allele suggests that the aggregation behavior might cause a weak starvation state, which is known to reduce growth rate and fecundity. Importantly, we show that variation in npr-1 causes each of these phenotypic differences through behavioral avoidance of ambient oxygen concentrations. These results suggest that variation in npr-1 has broad pleiotropic effects mediated by altered exposure to bacterial food.