Context. Dust in late-type galaxies in the local Universe is responsible for absorbing approximately one third of the energy emitted by stars. It is often assumed that dust heating is mainly attributable to the absorption of ultraviolet and optical photons emitted by the youngest (≤ 100 Myr) stars. Consequently, thermal re-emission by dust at far-infrared wavelengths is often linked to the starformation activity of a galaxy. However, several studies argue that the contribution to dust heating by much older stellar populations might be more significant than previously thought. Advances in radiation transfer simulations finally allow us to actually quantify the heating mechanisms of diffuse dust by the stellar radiation field. Aims. As one of the main goals in the DustPedia project, we have developed a framework to construct detailed 3D stellar and dust radiative transfer models for nearby galaxies. In this study, we analyse the contribution of the different stellar populations to the dust heating in four nearby face-on barred galaxies: NGC 1365, M 83, M 95, and M 100. We aim to quantify the fraction directly related to young stellar populations, both globally and on local scales, and to assess the influence of the bar on the heating fraction. Methods. From 2D images we derive the 3D distributions of stars and dust. To model the complex geometries, we used SKIRT, a state-of-the-art 3D Monte Carlo radiative transfer code designed to self-consistently simulate the absorption, scattering, and thermal re-emission by the dust for arbitrary 3D distributions. Results. We derive global attenuation laws for each galaxy and confirm that galaxies of high specific star-formation rate have shallower attenuation curves and weaker UV bumps. On average, 36.5% of the bolometric luminosity is absorbed by dust in our galaxy sample. We report a clear effect of the bar structure on the radial profiles of the dust-heating fraction by the young stellar populations, and the dust temperature. We find that the young stellar populations are the main contributors to the dust heating, donating, on average ∼ 59% of their luminosity to this purpose throughout the galaxy. This dust-heating fraction drops to ∼ 53% in the bar region and ∼ 38% in the bulge region where the old stars are the dominant contributors to the dust heating. We also find a strong link between the heating fraction by the young stellar populations and the specific star-formation rate.