This answer only applies to the UK.
tl;dr: only sometimes.
Purchasing items from export shops (formerly ‘duty free shops’).
You are legally required to present your boarding pass to export shops, but most airport shops are not export shops.
An export shop is a shop inside an airport that sells primarily alcohol and tobacco predominantly to passengers departing to destinations outside the European Union. Until 1999 they were called duty free shops.
Export shops can sell other products as well, and such a shop can sell products to passengers travelling within the EU, but more than half of its transactions must be in alcohol and tobacco going out of the EU. (Actually, they can sell less than fifty per cent, but then they have to keep their duty-free and duty-paid stock physically separated).
Further, Her Majesty's Revenue and Customs requires the shopkeeper to account for every single product sold and where it was going—including products to which no excise duty applies, such as phone chargers.
For those passengers not departing the EU, the shopkeeper must pay HMRC the duty owed on the alcohol or tobacco. HMRC specifically require the presentation of either a boarding pass or a airline ticket for this accounting process (unless you are on a private jet and didn't get a boarding pass, in which case a different arrangement can be made).
In particular, see section 8 of The Excise Goods (Export Shops) Regulations 2000.
Supplying passengers with excise goods
8.—(1) The authorized warehousekeeper shall not supply a person with excise goods from his export shop unless that person satisfies the warehousekeeper that he is a passenger by producing a transport document and such additional documents as the warehousekeeper may require.
The Regulation is supplemented by Excise Notice 197a.
There is also a requirement than the customer receive a receipt detailing the export, including his own flight number; ominously HMRC notes that this may be audited. If you have regular problems with HMRC, keep your receipt. If you did not receive such a receipt, then it was not an export shop.
Purchasing items from tax-free shops.
You do not have to present your boarding pass to the shop. (But the shop doesn't have to sell anything to you.)
This part of the answer is about VAT rather than duty. In this case, the shop will receive a VAT rebate from HMRC for selling products that are being exported out of the EU. (VAT only applies to sales on items that remain inside the EU, you as an individual can claim the VAT back on items you buy in the UK and then export.) The shop may or may not pass that saving on to you; some shops operate a dual pricing structure depending on your destination, but most have a flat rate and pocket the difference.
For the shop to claim as much VAT back as possible, the shop prefers to collect as many boarding passes as possible, in the hopes that you are travelling out of the EU.
But there is no legal obligation for you to present your boarding pass when purchasing from an airport shop (unless it is an export shop, discussed above). It is a private matter to be negotiated between you and the shop.
Money Saving Expert, Telegraph Travel