The massive mammal, about 15 metres long, was first spotted at Fremantle on Saturday, exhibiting concerning behaviour.
It reappeared on Sunday swimming in circles before beaching itself close to shore on Monday at Rockingham, in Perth's south, after being hit by a boat.
Authorities enforced a safety perimeter as hundreds of people gathered to see the whale, which was about 50 metres from the beach.
Marine mammal expert Kelly Waples said it was an unusual sight as sperm whales usually lived in deep water.
"It's never a good thing when see a whale like this so close to shore," she told reporters.
Before it died the whale was distressed and thin and resting on the sand, with the weight of its body pressing down on its organs.
"Normally this is an animal that's supported fully by the seawater," Dr Waples said.
"That kind of compression is a very bad situation to be in and it reduces its health even further."
Veterinarians worked through Monday to assess the whale that was partially protruding from the water and in poor condition.
It was found to be breathing very slowly and suffering.
Staff from Perth Zoo and the Parks and Wildlife Service then devised a plan to humanely euthanise it.
Authorities continued to monitor the whale throughout the night, saying there was little they could do to help due to its size and weight.
The animal moved into deeper water in the early hours of Tuesday morning but was reported to have died several hours later.
"Crews are maintaining a safety perimeter around the whale with additional vessels joining the operation early this afternoon, to assist with moving the carcass to a more secure location in the water, away from the beach," the Department of Biodiversity, Conservation and Attractions said on social media.
"The next stage of the operation will involve removing the carcass out of the water."