I've read a grammar rule. If you use a preposition and then a verb, it must end with "ing" Is it always true, or there are exceptions?
This is kind of tricky, let's see if I can explain...
As Claudiu pointed out already, gerund is the term. However, expanding on what he said, "a verb ending in -ing" is not necessarily a gerund; it could be a present participle. A gerund is an -ing form used as a noun (more precisely, as the head of a noun clause; it might still behave as a verb within the clause itself).
Thus, the rule you read is kind of okay, yet it is also kind of backwards. Being able to be preceded by a preposition is a nominal characteristic, not a verbal one. You can't really put a preposition in front of a verb — once you do that it needs to start functioning as a noun, and "normal" verbs can't do that. So you need a verb form that works as a noun. And that would be the gerund.
But what about this, you say:
Well, yeah, the verb fail somehow managed to start working as a noun all by itself. But again, the whole point is that when it acts as a noun it is, well, a noun; it is no longer a verb.
It seems to generally work. Be careful when you use "to". It might be denoting the infinitive:
I'm going to kill him.
or it might be used as a preposition:
I am used to crying all day.
As an aside, the technical term for "a verb ending in -ing" is a gerund.