Most behaviors that you describe occur because they are automatically reinforced (some people refer to these behaviors as "self-stimulatory"). In other words, engaging in the behavior produces a desirable consequence. Everyone engages in automatically reinforced behaviors of some sort or another; most typical people can discriminate when it is acceptable to engage in these behaviors, while many children with autism cannot. For example, if I am home alone, I may whistle and crack my knuckles, but I would not do those things in a meeting with my boss! So, one thing to start teaching is the difference between private and public environments.
For many children, automatically-reinforced behaviors such as this can occur when environmental stimulation is low. So, it is important to teach the child how to independently engage in activities that provide stimulation--especially those that may provide more stimulation than the problem behavior. I may sit at home and whistle and crack my knuckles when I am at home and have nothing to do, but if you gave me an IPAD, believe me, I would engage with that instead of ctracking my knuckles and whisteling! So, find leisure activities that he enjoys, teach him hoe to engage with them, and this may also be helpful in reducing some of these behaviors.
Best wishes to you and your family.
Rick
In my oppinion, sexual (self)stimulation in this case is need for two things:
1. reducing stressssss
2. feeling own the borders of own body
Try to imagine, that social rules are not self explaining for autistics. From autistic view, they are mostly absurd, ineffective and have to be learned with high cognitive efforts - and tolerating the irritation or cognitive dissonance to adapt those (absurd) behaviours.
So separating between inner motivation and outer requirements...
The humanoid system of sexual arousal is implemented basically before puberty, from (not later than) birth. There is no ejaculation before puberty, but the relaxing phasis at the end of orgasm can felt.
To avoid stimulation (looking) in public, it's necessary to avoid stressors (unknown situations/people/locations, crowds, people watching the kid directly) and focussing on well known objects (maybe a thing, which the kid is carrying whole time or things with simple geometrics and colour e.g. cube from plastics). In summary, try to substitute self stimulation.
Referring to Temple Grandin, maybe pressure to the body (e.g. if possible heavy jacket/vest or braces (suspenders? those old fashioned things to keep trousers up)) can help the kid to sense its corporal borders.