Why and when to use flaps?
Flaps change the camber of the wing's airfoil. This in turn changes the zero-lift angle of attack, increases the maximum lift potential and, in case of fowler-type flaps, the wing's area.

Airliners use flaps on both take-off and landing, and most of the time they are only partly deflected. Full deflection is only set on final approach to reduce the landing speed as much as possible.

When simple camber flaps are used, the drag increase is negligible for small deflections (±10° for a 20% flap), and they can be used for both take-off and landing. Other types of flaps are designed to increase drag (split flap, Zap flap) and should be used only for landing. If flight speed stays constant, a flap deflection will only change induced drag if it redistributes lift over the wingspan. Modern gliders use camber flaps inboard and flaperons (a combination of aileron and flap) outboard, and changing flap settings will not affect induced drag.

Generally, the purpose of flaps is to shift the minimum airfoil drag to the desired lift coefficient $c_L$. Especially laminar airfoils have a pronounced range of lift coefficients with low drag. The pilot should attempt to stay within this region of minimum drag, and flaps give him/her the means to achieve this. See below for an example of an airfoil at a Reynolds number of 1 Mio.



Flaps for lift increase work the same way, but change camber much more. Normally, they need to be combined with leading edge devices (slats) which change camber at the airfoil's nose to unfold their full potential. Below are some examples for flaps, in combination with proper leading edge devices. Note that the solid outline of the fowler flap is the position for landing, while the dashed outline is the position for take-off. $\delta$ is the relative chord of the flap.



Junkers flaps were the best way to control big aircraft in the days before more elaborate force compensation mechanisms were developed, and split- and Zap flaps were very popular in the 1930s. They are still used on smaller aircraft today. The simple Fowler flap is used on the C-130, and airliners use slotted flaps like the ones in the lowest two rows of the table above. 

Besides increasing drag, powerful flaps change the pitching moment of the wing by shifting the center of lift backwards, which requires sufficient tail size and control power. On airliners, the incidence of the full horizontal tail can be adjusted in order to create enough downforce to counteract the pitching moment. Note on the picture of the An-70 below that the stabilizer has a slat which operates in the opposite direction to that of the wing.