The flying flanker was sent off in the 93rd minute after the Video Assistant Referee caught him spitting in the face of Sassuolo's Federico Di Francesco, who had clashed with the Brazilian throughout the game.
Far from defending his player, Allegri placed the blame squarely on Costa, telling him to reign in his temper in the future.
"Maybe he was irritated at a foul before, but it doesn't matter, because this absolutely must not happen. The one thing we must avoid doing is falling for provocation," Allegri told 'Sky in Italy'.
"We could've scored a third goal, but instead we started to play as individuals, we tried to dribble past everyone, this wound up the opposition, who then reacted badly and you get to situations like Douglas Costa.
"You just had to see the first three games and how close Ronaldo went to scoring. Again today, he was a little too hasty and eager to score, but it bounced off the post and right into his path. That unblocked him."