Hmm I'm with you a bit on this marblemind, but it's true it's a life lesson (possibly in not being in the wrong place at the wrong time)
I simmer away quietly when this happens, but outwardly explain that teachers often just have to carpet bomb the area with tellings off, because they have so many to deal with etc. It's not always a fair result, but then again not always clear to teachers exactly what's occurred.
I had to explain peer pressure to dd(also 7) the other day when the whole school were punished for the misdemeanors of a few.
Ie the disapproval of your classmates who have been kept in too is a powerful tool used by teachers to get a minority to behave. She looked somewhat unconvinced.
I notice the teacher actually spoke to you though. That ups the ante a bit in my book.
As you are convinced ds is innocent, I might in your situation, just quietly 'update' the teacher. She did after all feel it noteworthy enough to mention the incident to you in the first place.
You could say ds is feeling a little aggrieved but that you have explained the life's not always fair bit to him.
As you weren't there I guess you can't take it further than that, but she will know that you have taken it seriously and discussed the incident further with ds.
I don't think it does any harm for teachers to know that you are keeping a close eye on school life and that you listen, talk to and believe your son.