We introduce a method for optically detected magnetic resonance for atomlike systems in an optical resonator. Driving the spin transitions of these systems with microwaves causes changes to the populations of the ground-state spin levels, which we detect by changes in the optical cavity frequency. The technique is useful for characterizing experiments aimed at quantum microwave-to-optical transduction because it provides a way of only probing the spin transitions of the atomlike systems that are in the optical resonator’s mode. We demonstrate the technique using a cryogenic erbium-doped whispering-gallery-mode resonator inside a microwave resonator. We compare our results with more standard electron paramagnetic resonance to show that our optical modes are confined to a region of large microwave magnetic-field amplitude. Our optical modes have a Q factor better than 108 making them the highest Q-factor resonators studied with cryogenic rare-earth-ion dopants, allowing us to report ensemble strong coupling between the erbium dopants and an optical whispering-gallery-mode resonator.