In insects, thoracic pattern generators are modulated by the two head ganglia, the supraesophageal ganglion (brain) and the subesophageal ganglion, which act as higher-order neuronal centers. To explore the contribution of each head ganglion to the initiation and maintenance of specific motor behaviors in cockroaches (Periplaneta americana), we performed specific lesions to remove descending inputs from either the brain or the subesophageal ganglion or both, and quantified the behavioral outcome with a battery of motor tasks. We show that 'emergency' behaviors, such as escape, flight, swimming or righting, are initiated at the thoracic level independently of descending inputs from the head ganglia. Yet, the head ganglia play a major role in maintaining these reflexively initiated behaviors. By separately removing each of the two head ganglia, we show that the brain excites flight behavior and inhibits walking-related behaviors, whereas the subesophageal ganglion exerts the opposite effects. Thus, control over specific motor behaviors in cockroaches is anatomically and functionally compartmentalized. We propose a comprehensive model in which the relative permissive versus inhibitory inputs descending from the two head ganglia, combined with thoracic afferent sensory inputs, select a specific thoracic motor pattern while preventing the others.