As a common neurotransmitter in the nervous system, γ-aminobutyric acid (GABA) modulates locomotory patterns in both vertebrates and invertebrates. However, the signaling mechanisms underlying the behavioral effects of GABAergic modulation are not completely understood. Here, we demonstrate that a GABAergic signal in C. elegans modulates the amplitude of undulatory head bending through extrasynaptic neurotransmission and conserved metabotropic receptors. We show that the GABAergic RME head motor neurons generate undulatory activity patterns that correlate with head bending and the activity of RME causally links with head bending amplitude. The undulatory activity of RME is regulated by a pair of cholinergic head motor neurons SMD, which facilitate head bending, and inhibits SMD to limit head bending. The extrasynaptic neurotransmission between SMD and RME provides a gain control system to set head bending amplitude to a value correlated with optimal efficiency of forward movement.