White stains inside the fireplace
Efflorescence, also called leeching, is deposits of salts on the masonry surface. It is caused by water soaking through the joints, dissolving the salts, and re-depositing them on the surface. Efflorescence is an early indicator of water damage, often seen inside the fireplace due to water pooling above the damper and soaking through. Fortunately, you can usually wash these stains off fairly easily.
The methods listed above for reducing water entry – a chimney cap, repairs to cracks or holes, and a water-repellent treatment – will reduce or eliminate efflorescence.
Black stains above or to the sides of the fireplace opening
Smoke stains around the fireplace opening are an indication of either (a) improper use of the fireplace, or (b) a smoking problem. First, correct the problem. Read about using your fireplace and make needed repairs or changes to solve smoking problems. Then, to clean stains on masonry surfaces, purchase a masonry cleaner at your local stove shop. This will be a liquid cleaner, usually in a pump-spray bottle.
Read the directions, and wear protective clothing like rubber gloves and goggles, as these cleaners often contain caustic agents.
Be aware that you will need to clean the entire surface, and not just the stained part, since cleaning the masonry surface will lighten it a bit. And don't expect to remove every trace of the stain. Mortar joints are porous, and draw stains in. It is practically impossible to completely remove a stain. But you will be pleasantly surprised at the difference a good cleaning will make.
If the stains are on non-masonry surfaces, such as painted walls, metal components of factory-built fireplaces, or wood mantels, try a mild household cleaner first. If it doesn't work, talk to a professional cleaning company or a smoke restoration company.
A special case
Sometimes smoke stains are caused by leaky gaskets around the frame of a fireplace door. Most doors incorporate a fiberglass gasket between the door frame and the masonry surface. If you have a set of doors and see "finger" shaped smoke stains around the outer edges of the frame, then you need to replace or fix this gasket. Since this generally requires removing and re-installing the doors, you might want to hire a chimney professional to do the job.