When you know your opponent is on a draw, and you hold a set, you want to bet the largest possible bet that he will call that gives him incorrect odds to continue.
So for example (in this example, I'm using top pair, but its pretty much the same with a set):
You have
, the flop is
Your opponent shows you
There is $10 in the pot currently.
Your bet must be bigger than his odds of hitting his flush on the turn. His odds of hitting the turn are 4.5:1. So our bet must be larger than $2.85 to have a positive $ expectation.
However, you want to bet as large as you think he will possibly call. So if our opponent will call a $100 bet, that is the bet we need to make.
We do not want our opponent to fold! Folding gets us no money. We want him to call incorrectly.