Painful or threatening experiences trigger escape responses that are guided by nociceptive neuronal circuitry. Although some components of this circuitry are known and conserved across animals, how this circuitry is regulated at the genetic and developmental levels is mostly unknown. To escape noxious stimuli, such as parasitoid wasp attacks, Drosophila melanogaster larvae generate a curling and rolling response. Rover and sitter allelic variants of the Drosophila foraging (for) gene differ in parasitoid wasp susceptibility, suggesting a link between for and nociception. By optogenetically activating cells associated with each of for’s promoters (pr1–pr4), we show that pr1 cells regulate larval escape behavior. In accordance with rover and sitter differences in parasitoid wasp susceptibility, we found that rovers have higher pr1 expression and increased sensitivity to nociception relative to sitters. The for null mutants display impaired responses to thermal nociception, which are rescued by restoring for expression in pr1 cells. Conversely, knockdown of for in pr1 cells phenocopies the for null mutant. To gain insight into the circuitry underlying this response, we used an intersectional approach and activity-dependent GFP reconstitution across synaptic partners (GRASP) to show that pr1 cells in the ventral nerve cord (VNC) are required for the nociceptive response, and that multidendritic sensory nociceptive neurons synapse onto pr1 neurons in the VNC. Finally, we show that activation of the pr1 circuit during development suppresses the escape response. Our data demonstrate a role of for in larval nociceptive behavior. This function is specific to for pr1 neurons in the VNC, guiding a developmentally plastic escape response circuit.