From day one pilots are taught to apply flaps necessary for take off as part of pre-takeoff checks.
Flaps do increase lft, but, as you rightly point out, also increase drag. The flap selected for takeoff is an amount of flap (determined by the Aeroplane's flight manual or checklist) that gives a good increase in lift over the penalty of an increase in drag. The idea is that the aeroplane gets airborne quicker (using less runway) and the initial climb angle (over obstacles or for noise restrictions)is increased. The flaps are then retracted at a safe altitude to provide better climb performance. Some light aeroplanes do not use flap at all for takeoff. The necessity of using or not using flap for takeoff is determined by test pilots.
Hope this helps.
Kermie