We investigate energy transfer by the radiation from a cavity quantum electrodynamics system in the context of quantum thermodynamics. We propose a method of decomposing it into work and heat within the framework of quantum master equations. We find that the work and heat correspond, respectively, to the coherent and incoherent parts of the radiation. In the derivation of the method, it is crucial to investigate the dynamics of the system that receives the radiation from the cavity.