first of all, it depends on context. sometime, both of them are correct but one of them is more popular such as (to let) (for sale) you can say (for sale and to let) but it's unusual.
some verbs can be follown only infinitive (such as need+to+infinitive)
some verbs can be follown only -ing form (such as enjoy+verb+ing)
some verbs can be follown verb+object+infinitive (such as (allow+object+to+infinitive)
there r some verbs can be follown infinitive and -ing form but with different meanings (for example. remember, forget, stop and try)
if u r talking about the past and u need to use (forget) u must use -ing form. Compare:
Don't forget to bring your book. (forget+infinitive= thinking about a future action)
I won't forget eating my first Italian spaghetti. (forget+-ing form= thinking about an earliar action)
thus, there are more details... but i think that might help to start.