Here is a table sorting out some essentials about using the gerund or the infinitive...
Tip for learning all this: jot down in your notebook all the verbs you find most often in your textbook, sorting them out in a table!
Both possible but gerund more common!
|Dancing keeps me fit.
No tredding on the grass
|To be or not to be...|
|after prepositions||I' m looking forward to seeing you.
He was accused of speeding.
I' m used to waiting.
They're thinking of moving.
Are you interested in learning other languages?
Sorry for keeping you waiting.
There's no point in arguing.
After swimming you feel cold.
Before doing that, think it over!
|in tenses||with continuous tenses...
present continuous: am/is/are studying
past continuous: was/were studying
present perfect cont.: has/have been studying
past perfect cont.: had been studying
future continuous: will be studying
future perfect continuous: will've been studying
conditional continuous: would be studying
conditional perfect cont.: would've been studying
|in simple tenses, after the aux...
present simple: I don't know
past simple: Did you see...?
future simple: Will you come?
|after modal verbs||Bare Inf (except full Inf with have to, ought to)
You must read this book! It's great!
Can I have a copy, please?
|verbal phrases||Purpose (less common than purpose infinitive):
for + gerund
I need those keys to get into my house!
There is more on this subject. Check out the Table of contents of Functional Grammar