Polar molecules offer a new platform for quantum simulation of systems with long-range interactions, based on the electrostatic interaction between their electric dipole moments. Here, we report the development of coherent quantum state control using microwave fields in 40Ca19F and 87Rb133Cs molecules, a crucial ingredient for many quantum simulation applications. We perform Ramsey interferometry measurements with fringe spacings of ~1 kHz and investigate the dephasing time of a superposition of N = 0 and N = 1 rotational states when the molecules are confined. For both molecules, we show that a judicious choice of molecular hyperfine states minimises the impact of spatially varying transition-frequency shifts across the trap. For magnetically trapped 40Ca19F we use a magnetically insensitive transition and observe a coherence time of 0.61(3) ms. For optically trapped 87Rb133Cs we exploit an avoided crossing in the AC Stark shifts and observe a maximum coherence time of 0.75(6) ms.