Inactivation of selected neurons in vivo can define their contribution to specific developmental outcomes, circuit functions, and behaviors. Here, we show that the optogenetic tool KillerRed selectively, rapidly, and permanently inactivates different classes of neurons in C. elegans in response to a single light stimulus, through the generation of reactive oxygen species (ROS). Ablation scales from individual neurons in single animals to multiple neurons in populations and can be applied to freely behaving animals. Using spatially restricted illumination, we demonstrate that localized KillerRed activation in either the cell body or the axon triggers neuronal degeneration and death of the targeted cell. Finally, targeting KillerRed to mitochondria results in organelle fragmentation without killing the cell, in contrast to the cell death observed when KillerRed is targeted to the plasma membrane. We expect this genetic tool to have wide-ranging applications in studies of circuit function and subcellular responses to ROS.