Cleaning guitars comes in two flavours: everyday maintenance and the occasional full-on scrub-down.
As Dave says, prevention is the first thing you should be doing. Keep a cleaning cloth handy and give the whole guitar a good wipe every time you finish playing. Slip the cloth under the strings (I find it's best to do this one string at a time) and run it across the full length of the string, bridge to nut, a couple of times. Wipe the body and the neck as well. You may want to use separate cloths for the strings and the body, because cleaning strings will make holes in the cloth pretty quickly. Plus, that's where most of the grime accumulates when playing. A painting brush is also useful, for getting dust particles out of hard-to-reach places, such as bridge saddles.
Every once in a while, however, you'll want to give your guitar a good cleaning and the best time to do this is when changing strings. To do this, you'll have to remove the whole set (a pain with floating-bridge tremolos, but worth the extra effort) and have some cleaning agents handy for the various parts of the guitar.
What you use to clean the body will depend on the finish. Most electric guitars have synthetic finishes, which are fairly robust and resistant to environmental insults, but some higher-priced guitars - Gibsons for example - have nitrocelulose finishes that require a little more care in choosing what you clean them with. French-polished classical guitars are even more demanding in this respect, since the finish is so delicate. When in doubt, get a purpose-made cleaner/polish from a music store.
Unless the manufacturer specifies otherwise, apply a small amount of the cleaning agent (which may be as simple as water with a bit detergent, if the finish has no special requirements) and wipe down the body and all other finished parts (which will probably include the headstock and maybe the neck). Pay special attention to the cutaways, since that's where grime tends to accumulate, and work into the light to see whether you've missed anything. Once you're satisfied that the guitar is clean, dry and buff the finish with a clean cloth.
Fingerboards deserve separate attention, which will depend on whether they've been lacquered or not. Rosewood or ebony fingerboards tend to be unfinished and should be cleaned either with a purpose-made fretboard cleaner or with a small quantity of lemon oil. Again, apply a bit to your cleaning cloth (a different one than the one you used for the body - obviously) and rub down the whole fretboard, taking special care to remove any dirt that has accumulated around the frets. If you have trouble removing this, try wrapping the cloth around a fingernail or pick. Having done that, wipe off any excess cleaner or oil and leave the wood to soak it in for a bit.
Lacquered fingerboards can be cleaned in a similar way as other finished guitar parts, but check the manufacturer's recommendations just in case. For unfinished necks, it would probably be best to simply use a moist cloth.
Any dust can be removed with either a cloth or a painting brush (as mentioned above). Chrome parts may be cleaned with a purpose-made cleaning agent, but this is seldom necessary. Remember to remove them from the guitar, if you intend to do so.
Always remember to read the instructions from the manufacturer of the guitar and any cleaning agents you use. When in doubt, keep cleaning agents away from exposed wood (including any chips in the finish) and use small amounts of cleaner.