Roma have recovered surprisingly well after their humiliating 7-1 Champions League drubbing at the hands of Manchester united last week and took the lead just before half-time when Perotta tucked home a Christian Chivu cross.
But normal business appeared to have resumed seven minutes after the interval when Marco Materazzi levelled via a dubiously awarded penalty for a foul on Adriano by Roma goalkeeper Alexandre Doni.
However the corks were put firmly back in the champagne on 88 minutes when Totti curled in a superb 25-metre free kick.
Cassetti wrapped the points up with a third in the dying seconds.
Inter's next occasion to wrap the title up will now come next week when they visit Siena. A victory in Tuscany accompanied by a Roma defeat to Atalanta is what the Nerazzuri need.
In other action on Wednesday, Inter's city rivals AC took another step towards a Champions Leagues spot by consolidating fourth spot with their comprehensive 5-2 win at bottom club Ascoli.
Rome and Milan are dominating the league this season with Lazio remaining third. They held on for a goalless draw with Chievo despite finishing the game with nine men.
Empoli beat Atalanta 2-0 but there was some good news for the losers as the former Italy striker Christian Vieri made his first appearance after a year of injury problems.
Livorno's Cristiano Lucarelli scored his 17th goal of the season in their 2-1 win over struggling Cagliari and Reggina continued their impressive fight to avoid the drop.
Docked 11 points for their role in last year's Italian matchfixing scandal the southern side beat neighbours Messina 3-1 and are four points clear of the relegation zone.
Vincenzo Iaquinta converted a penalty in the 53rd minute to separate Udinese and Sampdoria.