It can be done in the lounge, or the gate. I would suggest the lounge if you have access. The gates at LGW don't check for this, unlike LHR T5 since they don't have this concept of Ready to Fly. Gates agents have a tricky enough job that it's best to avoid leaving it until then, though they can certainly cope with a few stragglers there. But I always do it airside too, I'm usually arriving off the train or off Domestic Arrivals, and would rather avoid the "hike" over to Zone A. When Domestic moves to Zone B later the year I may revise this.
If you are doing an international connection into LGW South (for completeness) there is a BA desk just over the corridor from the entrance area to Flight Connections. They never look busy there, in fact I have only occasionally seen anyone use that desk. So I would do the ESTA check there.