Reinforcement:

Can you reinforce a more appropriate, alternative behavior to replace the maladaptive behavior (i.e. the private behavior in a public setting)?
If the student is likely to take a bathroom break during school or work to masturbate, what might serve as a more appropriate alternative? 

Here are a few ideas:

What are some reinforcing consequences you can deliver either immediately following the desired, alternative behavior – things that this particular student enjoys, wants, seeks out, etc.?

Consider how you might integrate those school and home-based reinforcers into a behavior plan or behavior contract.  It will be important to gain cooperation and consistency from the student’s parents and teachers. 

Are you using labeling and social praise to make the contingency between desired behavior and reinforcing consequence clear to the student?

Given the sensitive nature of this topic, you may need to deliver your praise in private, or in a discrete fashion (e.g. checkmark on card that the student can see, thumbs up or an agreed-upon nonverbal signal).

What reinforcing consequences can you arrange that are more naturally or intrinsically connected to this targeted behavior? 

If the student is motivated by social acceptance from peers, co-workers, and/or supervisors, it is likely that he would be motivated to refrain from private behaviors in public locations.  You can visually depict these natural consequences through such tools as graphic organizers and social narratives, and through modeling scenarios and video or written testimonials from peers.