We have achieved efficient electro-optic phase modulation at high frequencies in a resonant modulator cavity. We enhance modulation by matching the phase velocities of the optical and microwave fields in the modulator substrate and by placing the modulator inside an optical cavity that is resonant for the input optical beam and the generated sidebands. An optical frequency comb with a span of 3 THz and at a spacing of 17 GHz is generated with 1 W of microwave power. The terahertz comb is utilized to phase lock an optical parametric oscillator at a signal-idler difference frequency of 665 GHz.