Surely is energy is constantly being absorbed by the Earth it would just keep heating up for ever?
You are talking of grey body radiation, which means that the black body radiation is modified by the emissivity :
The SI unit for absolute temperature T is the kelvin. is the emissivity of the grey body; if it is a perfect blackbody, =1. In the still more general (and realistic) case, the emissivity depends on the wavelength,
The body absorbs less and emits less.
So a body at temperature T will absorb some energy E and its temperature will go up so it will radiate with the higher temperature. If the input radiance is much higher than the black/grey body radiation of the body irradiated, it will heat up until it combusts or melts or vaporizes. Fortunately the earth is far enough from the energy source to have reached an equilibrium , as we have seen by observations.The equilibrium can be disturbed by changes in the grey body constants, or by changes in the amount of energy impinging the earth. Then temperatures can go up, climate optima historically, or down, ice ages.
Vostok icecore measurements