Your body is very active at night. Not in the physical sense of moving around but in the biological/chemical sense. Sleeping actually plays an important part in thermoregulation, and lack of sleep has been shown to influence your body’s ability to thermoregulate itself.
Some things in your body are more active at night, your brain being one of them. While we sleep our brain activity amps up as it prunes unneeded neurons and clears out the gunk it has built up from the day, like defraging your computer. Your whole body strives for homeostasis and sleeping is a prime time to get rid of all the byproducts of metabolism that are generated as you function in day to day living. Since most of your conscious processes are put on hold, sleeping is the body’s prime time for “janitorial” work.
All the processes and chemical interactions still require energy to function and as such give off heat as a byproduct, which your body needs to manage by cooling itself off the only way it knows how.
However there are many things can interfere with your body’s metabolic pathways such as medications your take, low/high blood sugar, hormones (puberty/menopause), and stress levels. All these things, and a lot of other causes, can influence your body’s metabolism, which in turn plays a role in whether or not you will sweat at night.