A Gate-and-Switch Model for Head Orientation Behaviors in Caenorhabditis elegans