This is such an important technique in the kitchen that it almost deserves its own chapter, but because onions are what cooks typically sweat, by themselves or with other ingredients, sweating is a subtechnique of the onion.
Sweating means to gently heat the onion (or any vegetable) in a small amount of oil or butter without browning it. It’s called sweating because that’s what the onion appears to be doing; the heat forces water to the surface of the onion in little beads. As the onion loses water, its flavors begin to concentrate, and the heat transforms the sugars into increasingly complex and delicious compounds. If you want to taste the difference, simmer some raw onion in a small amount of water for ten minutes, and do the same with some onion that has been sweated first. The water with the sweated onions will be distinctly sweeter. Sometimes you want that raw effect. I prefer raw onions in most stocks, rather than cooked onions, because the finished stock can become too sweet, especially if you reduce it and concentrate the sugars. For the vast majority of preparations, we want to heat the onions first, and sweating is the most common of these steps.