Is this one of those things that unless you've been taught by an experienced person and you know what you're doing you probably just shouldn't try? If I did want to try, what precautions should I take? Is this a valid cooking method or is it mostly just done as an impressive visual effect?
Flambe is a valid cooking method. It allows you to flash off most of the alchohol from your chosen liqour but keep the flavour.
I'd suggest that you have a wet towel at hand or a fire blanket in your kitchen if you're going to embark on this cooking technique as a first timer.
Also don't run your extractor fan above the cooker if you're using your hob. You have the potential to draw in bigger flames and ignite any grease present in your filters or pipe to the outside world. My brother worked in a professional kitchen where this happened. They couldn't get the extractor turned off for a while due to the resulting fire and they managed to light up a good length of the extraction pipe to the outside. It was like the after burners on a jet engine. There was a fire appliance involved that night.
Ultimately it's all about common sense because fire and alcohol are a fairly dangerous combination.
Kev's answer mentions the most important aspects, but I'd like to add another observation that I believe is very important. Do not pour the liquor straight from the bottle into the pan. Not only is it very easy to accidentally use too much, there also is a risk of the liquor or its fumes catching on fire earlier than planned. This can happen especially easy with gas hobs because there's an open flame nearby. If the liquor would happen to ignite while pouring, you'd much prefer to have a small container of it in your hand rather than a molotov cocktail. So pour out the proper amount first away from the fire, preferably into something that won't shatter easily if dropped or heated, then close the bottle and put it away. Then when ready to flambé pour from the small container.
Spectacular though it may look, it is not something that only the most experienced chefs can attempt and is really not that hard. Just use some commons sense, think carefully about your actions, make sure proper precautions in case of trouble are in place before starting and stay calm if things don't seem to go well. Oh, and keep the pan at a slight distance during the whole process; it's not the time to hover over it and smell the aromas.
In addition to what other answers mention, I'd also recommend using a long match or a lighter with a long stem (as used for lighting fires). You don't want your fingers close to the pan when the flames start.
If you watch the pros do this on a gas stove, they'll often tip the pan slightly to get the gas from the stove to ignite the vapor above the pan to get things going, but I'd caution against trying this at the outset. It's harder to tell precisely when the flames will erupt, and without practice, it's possible to tip the pan too far, potentially spilling flaming liquid onto the stovetop (or the floor, or yourself).
I've also personally found that family members and guests like to hover around the stove when you do something like this, as it's not something they see everyday. Be sure to keep them at a safe distance (and preferably practice once or twice on your own before doing it with a large audience).