In an unfortunate incident like this, how is this matter handled?
In the event of a passenger dying on an airplane during flight, each case is different depending on the location of the airplane, the duration of that flight and the wishes of family or friends traveling with the deceased passenger.
What happens to the flight?
If the death occurs before takeoff or shortly after takeoff, the airplane is landed back to that airport or the nearest airport. If it happens mid-flight, normally the flight is continued to its destination.
Where is the deceased passenger placed?
If there is a seat available in first or business classes, the deceased person is moved there and covered with a blanket. If it is a full flight, that person may simply be strapped in more tightly and covered. This is done to ensure that the body is out of view of other passengers. A deceased person is never placed in the lavatory. It is not respectful and a major security concern.
What happens at arrival airport?
The arrival airport is informed in advance about the situation. Hence police, ambulance and coroner are available. Some airlines keep body bags on board. Normally the deceased person is placed on a stretcher and is carried from the rear exit of the airplane using a lift truck and then placed in an ambulance. This might be done after other passengers have exited the airplane.
What are the regulations?
FAA have regulations addressing several emergencies, but not specifically this one. An FAA spokesperson mentioned:
FAA spokesman Les Dorr said he was unaware of any policies that specifically address what should be done if someone dies in flight. The airlines make those decisions on their own.
This article mentions some incidents of this situation happening.
... there is one death for every 8 million passengers from the airlines [they] serve ...
Twenty years ago Singapore Airlines installed a special locker in their A340-500's which could be used if a passenger died on their ultra-long Singapore to Newark and Singapore to Los Angeles routes. According to a U.K. Guardian article from 2004:
The airline's new fleet of Airbus A340-500 aircraft boasts a discreet locker next to one of the plane's exit doors which is long enough to store an average-sized body, with special straps to prevent any movement during a bumpy landing.
Cabin crew have been instructed to use the locker in the event of a death on a long-haul flight - particularly if the aircraft is busy, with no free seats on which to lay out the deceased.
The aircraft came into use in February, operating the longest non-stop route in the world: a 17-hour, 7,900-mile journey between Singapore and Los Angeles.
Singapore Airlines operated their fleet of five A340-500's for ten years, and some reports say that the lockers were never used, however I'm not sure if it's possible to know that for certain. A Simple Flying article says that an airline spokesman told them that it "was likely never used", however that is far from being definitive.
Flight attendants are not allowed to declare someone dead so they would continue giving care until either (STAT-MD or A medical professional) declares them dead they would be put in a empty row or in first class (if flight is full they would be put back in their seat with blanket over them.