Polar molecules are desirable systems for quantum simulations and cold chemistry. Molecular ions are easily trapped, but a bias electric field applied to polarize them tends to accelerate them out of the trap. We present a general solution to this issue by rotating the bias field slowly enough for the molecular polarization axis to follow but rapidly enough for the ions to stay trapped. We demonstrate Ramsey spectroscopy between Stark-Zeeman sublevels in 180Hf19F+ with a coherence time of 100 ms. Frequency shifts arising from well-controlled topological (Berry) phases are used to determine magnetic g-factors. The rotating-bias-field technique may enable using trapped polar molecules for precision measurement and quantum information science, including the search for an electron electric dipole moment.