Direct imaging of extrasolar planets with future space-based coronagraphic telescopes may provide a means of detecting companion moons at wavelengths where the moon outshines the planet. We propose a detection strategy based on the positional variation of the center of light with wavelength, "spectroastrometry." This new application of this technique could be used to detect an exomoon, to determine the exomoon's orbit and the mass of the host exoplanet, and to disentangle the spectra of the planet and moon. We consider two model systems, for which we discuss the requirements for detection of exomoons around nearby stars. We simulate the characterization of an Earth-Moon analog system with spectroastrometry, showing that the orbit, the planet mass, and the spectra of both bodies can be recovered. To enable the detection and characterization of exomoons we recommend that coronagraphic telescopes should extend in wavelength coverage to 3 μm, and should be designed with spectroastrometric requirements in mind.