1. He knows it's hard to stop junk food.

2. He knows it's hard to stop eating junk food.

(Are both grammatical?)

Both are grammatically correct, but have quite different meanings.

Sentence 1 implies that he knows no one can stop the production of junk food.

Sentence 2 means he know it's hard for him to stop eating junk food.