This is difficult behaviour to break once started. One thing you must not do is square up to him, kick or attempt to beat the aggression out of him this will only reinforce the behaviour. Here's a cut and paste of some advice I wrote a while ago.
"Aggressive cockerels are a menace and can be dangerous. My daughter is still nervous around cockerels 10yrs after being attacked in her 20's. Fortunately she escaped with cuts to her face which healed though it just missed her eyes. Once they start this behaviour I've never succeeded in eliminating it entirely and I've tried all the standard advice such as holding them down, dousing/dunking in water/ showing them who's boss (the most cruel and futile approach). The trick if you can do it is to nip it early in the bud and don't trigger this developing by inadvertent behaviour. Below from my experience some basic rules to apply when a cockerel is running with hens.
1 Handle him as well as the hens from an early age.
2 When hand feeding, offer the food to the cockerel first and let him drop the first morsels for the hens. Note his head bobbing behaviour and picking up the food and dropping it for them. This reinforces his position as the provider and stops him seeing you trying to usurp his role.
3 Most developing behaviour starts with him knocking against the back of your leg to test your reaction and gradually becomes bolder. Don’t square up to him but face him and if he shows aggression try to be as passive as possible. Try not to turn your back and make sure he knows you are watching him and he generally won’t attack.
4 Check that a pair of colourful boots, flapping tongues or trousers isn’t a trigger.
5 Don’t kick him as this is guaranteed to encourage him to reciprocate.
6 Don’t appear to be luring away his harem. Indeed any behaviour which makes you appear to be a rival should be avoided.
7 If all else fails you can try the more dominating tactics if you like, or put up with it, though don’t expect a neighbour to look after them, or cull him as a danger.
Not every cockerel is sure to become aggressive though a high proportion (20 -30%) can."
Although I've not had success with holding a cockerel down or dunking him in cold water some people have and I think there may be a sticky on this topic that's worth a look. I expect the success of any measures you take are likely to be dependant on exactly what triggers it so if you can identify that you stand a better chance.
Regards
HF