How should I teach him a lesson so that he stop doing that by himself.
Welcome to MB. This is a terrible situation to find yourself in, and I am so sorry to read this.
The Marriage Builders programme, founded by Dr Harley, does not give recommendations about "teaching a spouse a lesson", especially not about sexual fidelity. The premise of the programme is that any one of us has the capacity to be attracted to someone else, which we must have had to fall in love and get married. We continue to have that capacity. The attraction to other people does not stop because we took vows. Vows and a wedding ceremony are not some sort of magic protection against ever seeing another person as desirable.
Instead, we need to stay away from situations in which we could grow close to people other than our spouse - including being in social situations with people at work, especially alone. Going with one person for coffee, going with one person to the pub, and talking to one person about our private lives are among the situations in which closeness can grow and an affair can result. Even socialising in groups without the spouse can lead to talking, flirting, and eventually warm feelings for another person.
Other situations include travelling away from home without the spouse, when it is all too easy to commit infidelity without anyone else finding out. Your husband seems to have the opportunity to travel without you, and the inevitable seems to be the result.
Dr Harley recommends a lifestyle change so that long-distance travel is eliminated. He also does not hold out much hope for people who take the opportunity to cheat whenever it is offered, or where they can find it (like actively choosing to visit prostitutes). He could seek out prostitutes at home. If he sees nothing wrong with this as long as you do not find out, he will continue to do it.
Will your husband change jobs? And how will you know if he ever again visits prostitutes in a nearby town? He doesn't need a dating app to do this. He doesn't need to use his phone at all.