Well I’ve read that in French the infinitive can be used in different ways, but as a start, here are two conditions to keep in mind.
First condition: when two verbs follow each other, the second is always in the infinitive (except when the first verb is avoir or être).
e.g. Je vais acheter du fromage. (“acheter” is in the infinitive because it is the second verb)
Second condition: If a verb follows a preposition (such as à, de, sans, etc.), then it is always in the infinitive form. For example, “sans arrêter”, “pour monter à Paris”.
e.g. J’ai passé toute la journée à ranger mes placards. (“ranger” is in the infinitive as it follows “à”)
Hope this helps. Bonne chance.