Whether to use the infinitive or the gerund for a verb's object depends on the verb itself.
Some take only the infinitive or the gerund only, or both. Sometimes the meaning may also change depending which one's used.
Here's the basics of it.
1. when the idea is about something which will happen in the future, or about a necessity, potential or expectation, or one's wish or preference, use the infinitive.
2. if it is about what already happened, something occurring routinely, use the gerund. Also, gerund is the only possible choice for an object of a preposition.
For example:
(infinitive)
- want to, wish to, prefer to, love to, hate to => about one's wish, liking, or intention.
- intend to, expect to, mean to, in order to, so as to => future, intention, potential.
- remember to, forget to => future, or a unique thing one has yet to do.
(gerund)
- keep -ing, repeat -ing => something occurring commonly.
- after -ing, on -ing, since -ing, because of -ing, on account of -ing => existing fact (it already happened).
- enjoy -ing, love -ing, hate -ing, miss -ing => one's general habits and preferences.
- about eating right, except coming in late => object of a preposition.
(some words can use either, with some nuance difference - I exaggerate the distinction below)
- I love to go with him => I wish to go with him on this occasion.
- I love going with him => I liked going with him in the past, so I I like to do it in general.
- I hate losing a friend => I hate it when I lose a friend (generally).
- I hate to lose a friend => I dread the possibility of losing a friend (at the moment).
- I remembered calling her: I remembered the fact that I called her in the past.
- I remembered to call her: I remembered that I must call her (future relative to the action of remembering).
- I stopped smoking: I stopped the practice of smoking (quit smoking).
- I stopped to smoke: I stopped what I was doing to have a smoke.