Associative learning allows animals to use past experience to predict future events. The circuits underlying memory formation support immediate and sustained changes in function, often in response to a single example. Larval Drosophila is a genetic model for memory formation that can be accessed at the molecular, synaptic, cellular, and circuit levels, often simultaneously, but the standard behavioral assay for learning and memory does not address individual animals. It has also been difficult to form long lasting memories, especially those requiring synaptic reorganization. We demonstrate a new assay for learning and memory capable of tracking the changing preferences of individual larvae. We use this assay to explore how activation of a pair of reward neurons changes the response to the innately aversive gas Carbon Dioxide, CO2. We confirm that when coupled to odor presentation in appropriate temporal sequence, optogenetic reward reduces avoidance of CO2. We find that learning is quantized, all-or-nothing, and can be extinguished by repeated unrewarded exposure to CO2. We find that memories can be stabilized against extinction by repeated training or overnight consolidation. Finally, we demonstrate long-lasting protein synthesis dependent and independent memory formation.