© 2014 ESO. Context. Dust reprocesses about half of the stellar radiation in galaxies. The thermal re-emission by dust of absorbed energy is considered to be driven merely by young stars so is often applied to tracing the star formation rate in galaxies. Recent studies have argued that the old stellar population might be responsible for a non-negligible fraction of the radiative dust heating. Aims. In this work, we aim to analyze the contribution of young (100 Myr) and old (~10 Gyr) stellar populations to radiative dust heating processes in the nearby grand-design spiral galaxy M 51 using radiative transfer modeling. High-resolution 3D radiative transfer (RT) models are required to describe the complex morphologies of asymmetric spiral arms and clumpy star-forming regions and to model the propagation of light through a dusty medium. Methods. In this paper, we present a new technique developed to model the radiative transfer effects in nearby face-on galaxies. We construct a high-resolution 3D radiative transfer model with the Monte-Carlo code SKIRT to account for the absorption, scattering, and non-local thermal equilibrium (NLTE) emission of dust in M 51. The 3D distribution of stars is derived from the 2D morphology observed in the IRAC 3.6 μm, GALEX FUV, Hα, and MIPS 24 μm wavebands, assuming an exponential vertical distribution with an appropriate scale height. The dust geometry is constrained through the far-ultraviolet (FUV) attenuation, which is derived from the observed total-infrared-to-far-ultraviolet luminosity ratio. The stellar luminosity, star formation rate, and dust mass have been scaled to reproduce the observed stellar spectral energy distribution (SED), FUV attenuation, and infrared SED. Results. The dust emission derived from RT calculations is consistent with far-infrared and submillimeter observations of M 51, implying that the absorbed stellar energy is balanced by the thermal re-emission of dust. The young stars provide 63% of the energy for heating the dust responsible for the total infrared emission (8-1000 μm), while 37% of the dust emission is governed through heating by the evolved stellar population. In individual wavebands, the contribution from young stars to the dust heating dominates at all infrared wavebands but gradually decreases towards longer infrared and submillimeter wavebands for which the old stellar population becomes a non-negligible source of heating. Upon extrapolation of the results for M 51, we present prescriptions for estimating the contribution of young stars to the global dust heating based on a tight correlation between the dust heating fraction and specific star formation rate.