Near-field and resonance effects have a strong influence on nanoscale electromagnetic energy transfer, and detailed understanding of these effects is required for the design of new, optimized nano-optical devices. We provide a comprehensive microscopic view of electromagnetic energy transfer phenomena by introducing quantum Langevin heat baths as local noise sources in the equations of motion for the thermally fluctuating electric dipoles forming dielectric bodies. The theory is, in a sense, the microscopic generalization of the well-known fluctuational electrodynamics theory and thereby provides an alternative and conceptually simple way to calculate the local emission and absorption rates from the local Langevin bath currents. We apply the model to study energy transfer between silicon carbide nanoparticles located in a microcavity formed of two mirrors and next to a surface supporting propagating surface modes. The results show that the heat current between dipoles placed in a cavity oscillates as a function of their position and separation and can be enhanced by several orders of magnitude as compared to the free-space heat current with a similar interparticle distance. The predicted enhancement can be viewed as a many-body generalization of the well-known cavity Purcell effect. Similar effects are also observed in the interparticle heat transfer between dipoles located next to a surface of a polar material supporting surface phonon polaritons.