As Zara said, could you tell us a little bit more about him? What does he do when you try to distract him, are there any toys he likes? What is he eating now? I would adapt the diet to more veggies if he eats them, but perhaps you already do that. I feed my two lovebirds who can get veeery hormonal, chop off a plate when they are out. The way it best when I hand them little pieces, and eating makes them unable to do anything hormonal. I think it is more time consuming for them to sort through veggies then eat seed/pellets. I did that in the morning with chop as breakfast for a while, that seemed to break the habit a bit. What works wonders for my guys, and I often forget to mention to others, is fresh branches and flowers. When the grasses in the neighborhood carry seeds, I pick a handful twice a day and they stay busy with it for a good while. Dandelion for example is also very nutritious. Mine also love willow branches. If you could get something like that, he might take a stop masturbating and go for that instead. I don't know how your boy is about playing, but when hormonal mine stop playing mostly, and this gets them going a bit again. I would also try to reserve special treats, like millet and sunflower, for training. Recall training tires my birds out pretty well, so I try to make them fly as much as I can. Try to get him foraging, that tends to help my birds too.
In this case, I would remove any object he loves on. Fëanor, one of my birds, kept choosing a perch to love. But as he was obsessed with it, like Boon, I kept replacing them with a different one. If there are certain places in his cage where he tends to get himself more worked up, I would put a toy there to destroy or something else he used to love. I noticed that would entice my birds to start playing with it a bit again.
Good luck with your boy, he is beautiful