The most common ways of being set on fire are: jumping onto a brazier, walking through a flame trap, or coming into contact with monsters or magic missiles that are already on fire.
The least favorable solution is simply to wait for the fire to go out which takes around 5 seconds. However, the best thing to do is to look around for a handy waterfall that can be used to douse your flame.
Being on fire will continue to sap your hp, often without anything you can do to stop it - don't play with fire!
It is noteworthy that a fire will coninue to spread between mobs so it can be an effective way of killing groups of enemies with low health. Just be careful if you have a large number of summoned creatures as you may find yourself trapped within a blazing inferno of skeletons.