Is a pilot allowed to sleep during a flight?
Airline flight crews generally consist of at least 2 pilots. One pilot is designated as pilot flying, the other is the pilot not flying, observing instruments and flight parameters. If required, pilots can use Flight Crew in-Seat Rest:


  Flight Crew in-Seat Rest
  This is the process whereby pilots may take short periods of sleep (naps), while temporarily relieved of operational duties in accordance with carefully prescribed ‘controlled rest’ procedures, when part of a two-man operating crew of an in-flight aeroplane. 


This is not communicated to ATC and only allowed with two pilots present on the flight-deck. It is prohibited to have both pilots participate in in-Seat Rest at the same time.

See also these related questions:How do pilots rest on long-haul flights?
What if pilot feels too tired before his flight?