First set up an objective tracking player death, similar to what I outlined in my answer heremy answer here. For the following, I assume that this objective is named hasDied
and there are two teams, red
and blue
.
Instead of the testfor
command in that answer, you can use
/testfor @a[team=red,score_hasDied=0]
Invert the redstone output, so that it turns on when nobody is left alive in team red
and continue from there. Do the same thing for the blue team.