Does an airplane has to take off from beginning of the runway or it can take off from displaced threshold?
Can the displaced threshold be used for takeoff?
The part of the runway in front of the displaced threshold must not be used for landing (it can be used from the other direction during roll-out), but it may be used for takeoff:


Displaced Threshold. A displaced threshold is a threshold located at a point on the runway other than the designated beginning of the runway. Displacement of a threshold reduces the length of runway available for landings. The portion of runway behind a displaced threshold is available for takeoffs in either direction and landings from the opposite direction.



(FAA AIM Chapter 2 - Section 3 - Airport Marking Aids and Signs)
This also follows the ICAO definitions in Annex 14, Volume 1, Attachment A, Volume 1, 3. Calculation of declared distances:


The declared distances to be calculated for each runway direction comprise: the take-off run available (TORA), take-off distance available (TODA), accelerate-stop distance available (ASDA), and landing distance available (LDA).

Where a runway has a displaced threshold, then the LDA will be reduced by the distance the threshold is displaced, as shown in Figure A-1 (D). A displaced threshold affects only the LDA for approaches made to that threshold; all declared distances for operations in the reciprocal direction are unaffected.




(Landing Distances on SKYbrary)
Note that the TODA (TakeOff Distance Available) is unchanged in D, but the LDA (Landing Distance Available) is reduced.
Does it have to be used for takeoff?
No, a takeoff can be performed starting from anywhere along the runway. This is typically called an intersection takeoff. Some airports even have taxiway signs displaying the remaining TORA at some taxiways:

(ICAO Standards - Airfield Information Signs)
Such an intersection takeoff requires ATC clearance and of course that the aircraft takeoff performance calculations are done based on this intersection. See also Are intersection takeoffs less common in the USA than in other countries?