When should I use exposure compensation, rather than ISO, shutter speed or aperture?
In all of the semi-manual modes (aperture-priority, shutter-priority and program auto), you set one or more settings manually. The camera then chooses the rest of the parameters automatically to give you a nominally correct exposure.
However, sometimes you want to override the camera's metering, either because it wouldn't correctly expose your subject or because you simply wish to take a creative decision to expose differently. In these kinds of cases, without exposure compensation, you would have to change to full-manual mode if you wanted to retain control over exposure.
With exposure compensation, the camera under- or over-exposes the image by the number of stops you dial in. However, the aperture or shutter priority remains in effect, allowing you to creatively control the exposure without losing the convenience of the camera selecting some of the settings for you.
This is both convenient and can save quite a lot of time, allowing you to get shots that you might have otherwise missed.
TL/DR; Use exposure compensation to adjust exposure in the semi-manual/creative modes. Use full manual mode when you need total control over all the settings (aperture, shutter and ISO).
The way exposure compensation (EC) works is by changing at least one of the three 'sides' of the exposure triangle: ISO, shutter speed (Tv), or aperture (Av).
Although the exact implementation will vary a little from camera to camera, in general it works like this:
Ultimately what determines a picture's Exposure Value is the combination of Aperture, Shutter Speed and ISO. There are many different ways to get from a specific scene to a specific exposure value. Exposure compensation is one way, but it is not the only way. Under certain shooting conditions changing from Evaluative/Matrix metering to Partial or Spot metering will accomplish the same thing as applying a couple of stops of EC. Using Center Weighted Averaging might fall somewhere in between. The key to knowing when to use what method is to practice, practice, practice until you find the method that works best for your shooting style and the lighting conditions you tend to shoot in the most.
Consider this scenario: You are shooting a performance in a theater. The house lights are totally dark. The stage lighting varies from one moment to the next as well as from one part of the stage to the next. Spotlights often follow the principle characters around the stage. The male lead is wearing a black tuxedo. The female lead is wearing a white dress. How would you shoot a series of shots as the conditions of the scene change rapidly? To further complicate things your client wants both tight telephoto shots and wider shots that show several characters in the scene together. Sometimes there will be a separate spot on each character with areas of darkness between them.
The best compromise will probably be to select partial metering, select your aperture using Av mode, and keep your thumb on the dial on the back of the camera that controls EC. As you compose each frame (or series of continuous shots during an action sequence), keep an eye on the Tv in the viewfinder to be sure it doesn't get too slow. Then change the EC as needed based on how much of the area being metered is lighter or darker than medium gray. When you are metering on the lady in the white dress, use about +1 to +1 2/3 EC. When metering on the man in the tuxedo, use around -1 to -1 1/3 EC. If your shutter values are consistently too slow you either need to open up the aperture (if you're not already as wide as you can go) or crank up the ISO.
The really short answer to this is to take a picture... If it's too dark, add some postive exposure compensation (EV). If it's too bright, add some negative EV.
Photos of a snow landscape often trick a camera's metering system, fooling it into thinking the scene is really bright and the camera underexposes to compensate. The snow then looks dull and greyish. Adding positive EV in this case brings the snow back up to being nice and white.
Alternatively, if shooting at night, the camera tries to increase the exposure to capture as much detail as it can. This leads to longer shutter times (possible blur), larger apertures (narrow depth of field), or higher ISO (noise). As you're shooting night, you actually want to retain the darkness, so negative EV will stop your camera from trying to be too intelligent and brightening the scene too much!