The hot subdwarf HD 49798 has an X-ray emitting compact companion with a spin-period of 13.2 s and a dynamically measured mass of 1.28+/-0.05 M_sun, consistent with either a neutron star or a white dwarf. Using all the available XMM-Newton and Swift observations of this source, we could perform a phase-connected timing analysis extending back to the ROSAT data obtained in 1992. We found that the pulsar is spinning up at a rate of (2.15+/-0.05)x10^{-15} s/s. This result is best interpreted in terms of a neutron star accreting from the wind of its subdwarf companion, although the remarkably steady period derivative over more than 20 years is unusual in wind-accreting neutron stars. The possibility that the compact object is a massive white dwarf accreting through a disk cannot be excluded, but it requires a larger distance and/or properties of the stellar wind of HD 49798 different from those derived from the modelling of its optical/UV spectra.