Hmm It's tough to answer as there is no formal rule for that (as far as I know). You might need to check out this link:
https://learnenglishteens.britishcouncil.org/grammar/beginner-grammar/verb-ing-or-verb-infinitive 
Just go through that to capture a general understanding. For your upcoming test, try to memorize as much as you can. For long-term learning, I would suggest you try to frequently read English text (news, books, Reddit...) to see how those sources use "to'' or "ing". The next thing you should do is trying to use them in a specific context (For example, your daily practices). You will not remember everything in the first place, but I am sure after repeatedly doing what I am telling you, you will be able to use them correctly and naturally without memorizing.