"Mario is 23 years old, he is no longer a child," Allegri told reporters about Balotelli's dismissal for insulting the referee at the end of the 2-1 home defeat by Napoli.
"To be a champion you have to have the right behaviour because you are an example to all those who are watching you," Allegri told reporters.
"Mario has made a mistake, penalising the team, the club and the supporters and he must change this behaviour."
Allegri added that referees were becoming reluctant to give free kicks to Balotelli because of his attitude.
"Mario should help the referees to protect him," he added. "The referees have left him (unprotected) because they can be influenced by negative attitudes."
The maverick forward has been relatively well-behaved since joining Milan from Manchester City in January, although he was also sent off against Fiorentina in April, again for arguing with a referee.
"I hope that he realises he put the team in difficulty," said Allegri. "When the game is over, you need to go into the dressing room, calm down and think about working to improve."
"The players should think about playing and not about the referee's decisions," he added. "When the game ends, you should leave the field, possibly greeting the referee politely."
"Mario is a world-renowned player who represents the Italian national team. I think he has every chance of understanding and growing. He is an important player for Milan and should behave like a champion.
"Until now, Mario has always behaved well. He got it wrong on Sunday and I hope that serves as a lesson."