The erect state of his penis indicates this is most likely discipline (play) rather than punishment. It could also be part of a longer edging session where directed discomfort for his testicles is being used to keep him from going over the edge. A more devious Dom(me) will have those balls spanked until he’s limp and re-start edging him from there.