If your baggage is checked through to your final destination, that's where you clear customs. If you're collecting your baggage and checking in to your next flight yourself, you need to pass through customs at Heathrow.