In sentence #1, to stick to my goals is an infinitive phrase introduced by to stick.
In sentence #2, sticking to my goals is a participial phrase introduced by the participle sticking.
They are both correct.
As Anglika noted, the meanings are the same. The late, great linguist, Dwight Bolinger proposed that the infinitive denotes a more distant, a "not at the present moment realized" action while the 'ing' form had a tendency to be used more in the moment of the action.
I like camping - said while camping
I like to camp - said while not camping
I think that measured for overall frequency, this idea may have some merit but it must be noted that we aren't in any way prohibited/prevented from using either form at any particular time. Mr Bolinger mentioned that too. I don't know of any studies that have tested this hypothesis.