Please consider these rules about the "rules" of punctuation:
Punctuation is a matter of style, not grammar. English grammar has rules that you must follow if you wish to be understood. If you wish to convey in three words the thought that "John loves Mary", English requires that the syntactic subject John precede the syntactic object (and that of his affections) Mary. You cannot reverse the order and not be misunderstood. The same cannot be said of punctuation. The "rules" are conventions.
Which set of conventions, usually collected in a manual of style, that you follow depends on your audience, your topic, and most crucially on the persons who have assigned you your task. These last often have a manual that they will require that you follow. When James Joyce wrote Ulysses, he was writing experimental literature to please himself. He famously wrote Molly Bloom's soliloquy as 3688 words, from the initial uncapitalized "no" to the final capitalized "Yes" without any punctuation. You will likely not be granted that freedom, and if you are, it's probably best that you not take it unless your stature as a writer equals Joyce's.
A good manual of style (I use the Chicago Manual of Style) is one that has been tested in publication. Such manuals will explicitly declare that judgment and good sense are more important than rigid formulas and that careful writers will run into exceptions to the stated guidelines.
The purpose of punctuation, a creature of the written word, is to guide your readers in parsing your unidirectional, linear text -- text that requires they jump back and forth to follow references as they build a parse tree so different from a line. Your readers must accomplish this task without pauses, intonation, modulation, facial expression, and body language. Punctuation can make this task easier, giving clues, for example, to the crucial difference between the famous pair of sentences
Let's eat, Grandma
Let's eat Grandma.
I hope the first answerer doesn't mind my musings on the answer given, but who says that in general five words marks the boundary between a comma's presence following an introductory phrase and its absence? Synonym.com? That's a site owned by Demand Media, a company founded by the former head of MySpace. According to Wikipedia, Demand Media spots topics likely to support advertising and then hires freelancers to provide content on those topics.
Purdue OWL? If you're not writing papers to be graded by Purdue professors, is OWL the proper guide for you? Both sites are concerned with counting words in introductory prepositional phrases, but these creatures are part of the larger group of introductory adverbial phrases, and per CMS -- and consider whether or not CMS is a good fit with your writing -- it is these constructs that "frequently" take a following comma unless the phrase is "short". How short? Don't count; try to decide what's best for your readers.
There are numerous situations that require the exercise of judgment. Try this eight-word introductory prepositional phrase:
From the intricacy and complexity of Section 2 will arise the clarity of Section 3.
Would you put a comma after "Section 2"? CMS will advise no, and for good reason.
How about these short introductory prepositional phrases:
After Section 2, Section 3 will provide more detail.
In Section 2, 21 examples will illustrate the premise.
Would you omit the commas after "Section 2"?
The lessons here aren't that OWL is "bad" and that CMS is "good". The lessons are that punctuation has a purpose, style guides have a function that is not oracular, and that your judgment is indispensable. In short, nobody can be "exactly sure" all the time when you should use a comma in an introductory phrase. However, you, your editors, and your readers can become reasonably comfortable with your decisions.