How does the Earth lose heat?
Planets have some heat.
The Earth and other planets retain some residual heat left from the time planets and the Sun were formed four or five billion years ago. In addition, there are some internal sources of heat such as radioactive decay. Earth and other planets also gain heat from the Sun.
Planets lose heat.
Overwhelmingly, the mechanism for heat loss is through radiation of heat. All objects radiate heat in the form of electromagnetic radiation. (One can look up "black body radiation" which is an interesting topic in its own.) For Earth, this is typically characterized as infra-red radiation. The radiation is emitted from the Earth, through the atmosphere and heads out into cold space.
(Space, all the apparent emptiness we see in the night sky, is at a temperature of about 4 degrees Celsius above absolute zero, compared to our temperature of almost 300 degrees above absolute zero. The cooling through radiation of the hot Earth is evident in our daily lives because the cooling we experience at night can be so dramatic. In particular, clouds prevent much infrared radiation from directly escaping. A cloudy night cools several degrees less than a clear night.)
There are complications.
Though there is no question that the Earth loses heat by radiating it into space, the details get complex. There are a lot of complications about how much energy of this sort is absorbed by the atmosphere and that leads to discussions of the Greenhouse Effect, but that can be left to another question. The greenhouse effect is quite real and part of the complex balance of energy incoming and energy radiated that can occupy a long discussion.