An analytical approach is proposed to calculate the stead-state three-dimensional temperature distribution in multilayered structures, particularly when containing periodic stacks. We apply this model to the case of vertical-cavity surface-emitting lasers under optical pumping and find an excellent agreement with experimental results.