Historically speaking, it’s incredibly difficult to restrain an army from sacking a city that falls during a siege. For example, Holy Roman Emperor Charles V, as devout a Catholic as one could find in the Reformation and the most powerful man in Europe, couldn’t stop his largely Catholic army from sacking Rome – massacring the Swiss Guard almost to a man on the steps of St. Peter’s, looting almost every church and shrine in the whole of the city, and killing between 6-12,000 civilians. And that wasn’t a case where his men had their blood up – Charles V hadn’t paid his men in a while, so they just took their wages in plunder.
As for Tywin, he didn’t care. I doubt he gave an order – his orders were to eliminate the royal family, which was the main political priority – because as far as he’s concerned, the smallfolk do not matter. His men sacking the city allows him to avoid paying some wages, so why not?