The rule is: there is no rule.
Punctuation is intended to add clarity to a body of text. If punctuation after a formula does so, put it in. If it does not, leave it out. My default is to put it in on the principle that the mathematics expressions are part of the text and therefore subject to its rules. However, this can conflict with comprehension particularly where the punctuation can be mistaken for a part of the formula.
As a guideline, I would say that for short formulae, put it in (for example, in your example in your question) since the reader can read those quickly enough that they don't lose the thread of the text. However, the average reader cannot parse larger formulae so quickly and so will effectively stop reading in order to understand the mathematics, then start reading again afterwards. Thus the formula itself acts as a sort of punctuation mark and so does not need any further adornment.
Of course, there are always grey areas (even gray ones) and that's where you'll find the most vociferous eraser fights. But the zeroth law (or, if you prefer, Rule 42) is: the one that makes it clearest is the right choice.