Photoswitchable ligands can add an optical switch to a target receptor or signaling cascade and enable reversible control of neural circuits. The application of this approach, termed photopharmacology, to behavioral experiments has been impeded by a lack of integrated hardware capable of delivering both light and compounds to deep brain regions in moving subjects. Here, we devise a hybrid photochemical genetic approach to target neurons using a photoswitchable agonist of the capsaicin receptor TRPV1, red-AzCA-4. Using multifunctional fibers with optical and microfluidic capabilities, we delivered a transgene coding for TRPV1 into the ventral tegmental area (VTA). This sensitized excitatory VTA neurons to red-AzCA-4, allowing us to optically control conditioned place preference in mice, thus extending applications of photopharmacology to behavioral experiments. Applied to endogenous receptors, our approach may accelerate future studies of molecular mechanisms underlying animal behavior.