[show abstract][hide abstract] ABSTRACT: Many animals use their olfactory systems to learn to avoid dangers, but how neural circuits encode naive and learned olfactory preferences, and switch between those preferences, is poorly understood. Here, we map an olfactory network, from sensory input to motor output, which regulates the learned olfactory aversion of Caenorhabditis elegans for the smell of pathogenic bacteria. Naive animals prefer smells of pathogens but animals trained with pathogens lose this attraction. We find that two different neural circuits subserve these preferences, with one required for the naive preference and the other specifically for the learned preference. Calcium imaging and behavioral analysis reveal that the naive preference reflects the direct transduction of the activity of olfactory sensory neurons into motor response, whereas the learned preference involves modulations to signal transduction to downstream neurons to alter motor response. Thus, two different neural circuits regulate a behavioral switch between naive and learned olfactory preferences.