Which sentence is correct:
Why don't you try to give up candy if you want to lose some weight?
Why don't you try giving up candy if you want to lose some weight?
Both sentences are correct. They have a different meaning.
“Try to” implies that the action that is attempted may or may not succeed. Try to give up candy; maybe you will succeed in refraining from eating candy, or maybe you will succumb to the temptation and eat candy anyway.
“Try + -ing” indicates that the action may or may not have the desired result. Try giving up candy; if you do give up candy, maybe you will lose weight, or maybe you will not.