Hello,
Deserve + gerund is not common but it is occasionally used in passive constructions or where there is an empasis on the PASSIVE meaning.
There is very little difference in meaning between...He deserves punishing....and....He deserves to be punished.
Examples:
The idea deserves considering.
The idea deserves being considered in detail.
The student deserves punishing..... This means that the student deserves
-the punishment that he is receiving now (passive)
-or will receive in the future (the same as ...to be punished).
The student deserves to be punished.... The 'to be' infinitive + past participle is the more common way to express the passive meaning. This expresses the future, arrangement in advance of a present punishment, or an obligation of punishment.