Villa, who is set for a three-month spell in Australia with Melbourne City after, became the fourth Spanish player to score in three World Cups when he backheeled home Juanfran's cross for his 59th international goal in his 97th and final appearance for La Roja nine minutes before half-time.
FINAL GROUP B STANDING
Netherlands: Played 3, Won 3, Goals For 8, Goals Against 3, Points 9
Chile: Played 3, Won 2, Lost 1, GF 5, GA 3 Points 6
Spain: Played 3, Won 1, Lost 2, GF 4, GA 7, Pts 3
Australia: Played 3, Lost 3, GF 3, GA 9, Points 0
Andres Iniesta then marked his 100th cap for his country with a lovely through ball for Torres to double Spain's advantage on 69 minutes before Mata slotted home a third eight minutes from time.
Victory means Spain finished third in Group B behind Chile and group winners the Netherlands, whilst Australia slipped to a third consecutive defeat.
The Spaniards left for the airport straight from the ground after their win
The Aussies had started with the energy that had characterised their two encouraging performances against Chile and the Netherlands, but without the suspended Tim Cahill lacked a threat in the final third.
Mathew Leckie pulled a shot well wide for the Socceroos on five minutes, but as the half developed Spain began to take control with Villa particularly prominent.
The former Barcelona and Atletico Madrid striker first went close when his volley from Iniesta's pass at the far post skewed wide.
Australia keeper Maty Ryan then had to beat away Jordi Alba'a driven shot from a narrow angle before Villa very nearly set up the opener with a low cross that the late arriving Koke and Torres just couldn't turn home.
Villa did finally get his goal on 36 minutes with a lovely backheeled finish from Juanfran's low cross to extend his record as Spain's leading scorer of all time.
Koke came close to making it 2-0 before half-time when his long-range shot was tipped behind by Ryan.
Del Bosque surprisingly replaced Villa for Mata just before the hour-mark as the game continued to labour at a slow pace. Matt McKay sent a dipping volley over the bar as Australia looked in vain for an equaliser that would deliver their first point of the tournament.
However, their hopes were killed off when Iniesta released Torres in behind the Australia defence and he coolly slotted beyond Ryan into the far corner.
Mata rounded off the scoring eight minutes from time when he controlled Cesc Fabregas' lofted pass and rolled the ball through the legs of the helpless Ryan.
And the scoreline could even have been worse for Australia as David Silva fired just wide and Matthew Spiranovic blocked a goalbound effort from Mata in the closing minutes.