Since you offered.
Is inflicting pain the proper way to stop a child from doing dangerous things (running across the street/touching a hot pot).
Short answer - not really. There will always be contextual variables that come into play that can potentially impact any given behavioral outcome (and there are also individual differences in the ways we respond to different forms of consequences), but as a general rule, no - research indicates that punishment isn't generally all that effective in minimizing unwanted behavior unless there are several specific criteria met.
It should be added that corporal punishment, while legal, has been found to be the best predictor of aggression in children, and has been linked to lower levels of moral internalization and decreased mental health, including adolescent depression and social anxiety. I know this goes beyond your question, but is worth mentioning for those who go beyond the slap on the wrist when running in the street...
Back to the idea of punishment (or in the case of your question, "inflicting pain"), lab studies conducted on rats, monkeys, and humans demonstrate that it is almost impossible for punishment to successfully reduce an undesired behavior in real life. The way for punishment to actually reduce an undesired behavior is when it is:
-highly intense
-consistently applied
-no delay between the behavior and the punishment
-there are no competing rewards for the same behavior
So if you are extremely consistent, punish the child immediately and harshly, eliminate any social rewards for performing the behavior, then you may be ultimately successful at getting a child to stop performing the behavior. However, if if applied in this way, it is not an argument for inflicting pain, as a harsh punishment can be applied without doing so. Also, most people don't apply punishments in the way detailed above.