Heat transfer by conduction and convection works by particles colliding and transferring energy, as there are no particles in a vacuum heat transfer can only occur by radiation. This is because radiation involves electromagnetic waves, not particles, and is therefore able to transmit heat across a vacuum.
radiation
Unlike conduction and convection, radiation does not need matter to transfer heat. Energy is radiated from the sun, through the vacuum of space at the speed of light.
But radiation — heat transfer via electromagnetic waves — can occur across a vacuum, as in the sun warming the Earth.
Learn more about heat transfer in vacuum here: