Middle ear infection

Recently, one of my students experienced a lot of problems equalizing during his descent. He managed to descend, but after the dive his ear remained painful. He consulted a physician who diagnosed an ear infection.
My question is: is it possible that this ear infection was caused by the dive and/or the equalizing problems, or is it more likely that the ear infection was already there and caused the equalizing problems (and was maybe aggravated by the equalizing problems)?

Undertreated or mistreated Middle Ear Barotrauma can indeed end in infection of the middle ear. Also it is true that any infection or inflammation of the middle ear or the upper respiratory tract can facilitate or precipitate middle ear barotrauma and, in a vicious circle, further aggravate infection..
Difficult to say what happened in the case you describe, as both mechanisms are equally possible. Given the problems experienced by your student, it may be that an inflammation of the middle ear was already present. Whether it was alerady infected or not, it is impossible for me to say.