Any traveller landing on US Soil from overseas must clear US Customs at their point of entry, even if they are not travelling to the US. I am told the reason is US International Departure Gates arenot sealled Customs Areas, unlike the rest of the world, therefore you are officially in the US if you are at one of them and therefore you must pass through customs. In any other case to the best of my knowledge, if you are just transiting you will remain in the Customs Secure Airside and therefore you donot officially enter the country you are transiting in and therefore donot pass through customs. This has been the case since the year dot, oddly enough my mum is at this very moment flying United from London to Sydney and had to clear US Customs at sfo last night. She's been flying that route for 40 years and has always had to do that.
Hope that helps