I've read that at certain airports (especially London airports), there are sometimes American DHS officers doing spot checks of passengers about to board flights to the US.
At what airports is this the case?
According to an EU document, in 2013 the program comprised 11 airports in 9 countries. CBP does publish a list of embassies where it has posted attachés, but this currently comprises 24 countries, and the scope of the attachés' duties is rather wider than just the IAP. It is probably safe to say, however, that airports outside of those countries are not in the program.
There is also a somewhat meager page on international engagement at CBP's parent department, the Department of Homeland Security.
The Government Accountability Office published a report in 2017 that identifies the airports in the IAP and the related Joint Security Program (JSP). They are
Since that seems to be eleven airports in nine countries, it is possible that the EU document may have considered the two programs together. The description of the program officers' authority is germane to some of the comments on the question:
Immigration Advisory Program (IAP) and Joint Security Program (JSP). IAP and JSP operate at foreign airports. According to CBP officials, under this program, unarmed, plain clothes CBP officers posted at foreign airports partner with air carriers and host country government officials to help prevent terrorists and other high-risk individuals from boarding U.S.-bound flights by vetting and interviewing them before travel.19 According to CBP program documentation, CBP established IAP in 2004 to prevent terrorists, high-risk, and improperly documented travelers from boarding airlines destined to the United States. Building on the IAP concept, CBP established JSP in 2009 to partner with host country law enforcement officials to identify high-risk travelers. CBP officers at IAP and JSP locations have the ability to question travelers and review their travel documents. They are to act in an advisory manner to the air carriers and host governments and do not have authority to deny boarding to individuals on U.S.-bound flights or fully inspect travelers or their belongings. IAP and JSP officers are authorized by CBP to make recommendations to airlines as to whether to board or deny boarding (known as a no-board recommendation) to selected travelers based on their likely admissibility status upon arrival to the United States. The final decision to board travelers, however, lies with the carriers.
Footnote 19 is a reference to 8 USC 1225a(b), which mandates immigration preinspection at foreign airports.