Special quantum states are used in metrology to achieve sensitivities below the limits established by classically behaving states1,2. In bosonic interferometers, squeezed states3, number states4,5 and ‘Schrödinger cat’ states5 have been implemented on various platforms and have demonstrated improved measurement precision over interferometers using coherent states6,7. Another metrologically useful state is an equal superposition of two eigenstates with maximally different energies; this state ideally reaches the full interferometric sensitivity allowed by quantum mechanics8,9. Here we demonstrate the enhanced sensitivity of these quantum states in the case of a harmonic oscillator. We extend an existing experimental technique10 to create number states of order up to n = 100 and to generate superpositions of a harmonic oscillator ground state and a number state of the form \(\frac{1}{\sqrt{2}}\left(\left|0\right\rangle +\left|n\right\rangle \right)\) with n up to 18 in the motion of a single trapped ion. Although experimental imperfections prevent us from reaching the ideal Heisenberg limit, we observe enhanced sensitivity to changes in the frequency of the mechanical oscillator. This sensitivity initially increases linearly with n and reaches a maximum at n = 12, where we observe a metrological enhancement of 6.4(4) decibels (the uncertainty is one standard deviation of the mean) compared to an ideal measurement on a coherent state with the same average occupation number. Such measurements should provide improved characterization of motional decoherence, which is an important source of error in quantum information processing with trapped ions11,12. It should also be possible to use the quantum advantage from number-state superpositions to achieve precision measurements in other harmonic oscillator systems.