In this case you are doing work (lifting weights, or building a house) and it is causing you to sweat. Here are a couple examples: "I am working up a sweat lifting all these heavy rocks" or "I like going to the gym (or health club, or fitness club) and working up a sweat."
In most cases when we use 'working up a sweat' the focus is on the activity we are doing, not the actual sweating. We aren't bragging about how active our sweat glands are, we are pointing out that we are doing something difficult (hard work, or exercise).