The theoretical analysis of the energy relaxation of an electron-phonon system of metal nanoparticles embedded in a dielectric matrix is usually based on semiphenomenological dynamic equations for electron and phonon temperatures (two-temperature model), which does not take into account the non-thermal nature of the phonon distribution function. In this work, we use a microscopic model that describes the dynamics of the electron-phonon system of metal nanorods and metal spherical nanoparticles in terms of the kinetic equation for the phonon distribution function. We focus on the size effect in the transfer of heat from a nanoparticle to a dielectric matrix. If the dimensions of the nanoparticle are much larger than the phonon-electron mean free path, then the heat transfer is determined by the properties of the interface between the nanoparticle and the matrix. In the opposite case, heat removal is determined solely by the parameters of the electron-phonon interaction in a metal nanoparticle. The dynamics of cooling of nanoparticles is also considered and the dependence of the electron temperature on time is obtained.