Don't take this as formal advice on the matter, as I have no particular expertise in the area.
The duty payable on beer is governed by the Alcoholic Liquor Duties Act 1979. There are likely to be subsequent amendments but the bulk of the legislation appears to sit here.
Section 1(1) says that beer is subject to duty.
Beer is defined in s.1(2) as "includes ale, porter, stout and any other description of beer, and any liquor which is made or sold as a description of beer or as a substitute for beer and which of a strength exceeding 0.5 per cent." [I believe this has subsequently been amended to 1.2%]
For completeness, it "does not include—black beer the worts whereof before fermentation were of a specific gravity of 1200° or more" [I think this black beer reference then takes you to a different duty charge - perhaps the strong beer category??]
Section 41 provides us with the Homebrewer exemption and says "The duty on beer produced in the United Kingdom shall not be chargeable on beer produced by a person who produces beer only for his own domestic use."
So that's the law - duty on anything over 1.2% unless you produce it yourself for your own consumption. This suggests you can't even give it away!
But then we have to look at what HMRC might enforce, which is where their guidance comes in. HMRC's guidance is not legally binding on either party, so they could prosecute someone even where they adhere to the guidance, if the law says something else.
The key phrase from HMRC's guidance is "If you produce beer for commercial reasons and its strength exceeds 1.2% ABV, you must pay Beer Duty."
There is no specific definition given for "commercial reasons", and so we would have to take its ordinary meaning.
Gifting beer to someone, i.e. sharing with friends and family or other homebrewers for free, is not likely to amount to a "commercial" situation. I would suggest we're reasonably safe on that front and don't need to close down the forum competitions.
In terms of selling for charitable purposes, you could read "commercial" in various ways. Either, it's interpreted pretty widely as covering any situation where you're selling it to anyone; narrowed slightly in saying it applies to sales to the public; or very narrow in that commercial reason is with a view to making a profit.
It should be noted that I believe there are plenty of legal references out there to how charities can still have commercial reasons, e.g. charity shops are likely to be commercial ventures in many respects, notwithstanding the charitable intention.
Also worth noting is that HMRC talk about "commercial reason" and don't explicitly state "where beer is sold" or something similar, i.e. could this mean HMRC accept there might be situations where beer is sold but this is not a commercial situation? Dunno.
To conclude, the law seems relatively clear on what is and is not subject to duty. You may take comfort in the argument that HMRC will only seek to enforce duty where you are trying to make a profit from selling the beer, but that's a risk you take. Perhaps they have bigger fish to fry and wouldn't worry too much about someone selling a handful of beers to raise some money for charity.