No it's not against the law, but there's a risk it could be a proxy sale. If the teen isn't there then the shop assistant has no reason (unless someone says this is for my 15 year old of course!) to suspect it might be a proxy sale, if it's a very young child then less reason than if it's a teen.
When someone underage (or without ID even if over age) is present then that increases the risk it's a proxy sale, that person being 'involved' like handling or choosing etc also increases the risk it's a proxy sale, conversations about it increase that risk.
As the person selling it you're responsible if that alcohol does end up in the wrong hands and you have to prove that you took all reasonable precautions to prevent that happening.
"Well they told me it wasn't for the underage person and that they are his mum, would never let him drink and it's for her" isn't a defence for the person selling it despite any of the 'warning' signs associated with a proxy sale, because people lie to get what they want and parents do buy alcohol for their underage kids, you have to be able to show that there was no reason for you to suspect this was a proxy sale if something goes wrong and it ends up with a 15 year old in hospital for example, not that the person attempting to buy told you it was ok so it must be.
Or if the teen leaves after the refusal and then the person attempts again, the sale should still be refused on the same grounds. If they go through a different cashier then that changes things because shop assistants don't have a hive mind.
And as for pubs and restaurants, you can drink if 16/7 (certain things and with a meal only) and bought by someone over 18. And the staff are in a better position to monitor who the alcohol ends up with. I have served people and then asked a young looking person who's been bought a drink for ID and removed it if they can't supply that ID, in fact I got a bit of a talking to from licencing for serving someone who then passed that on to two younger people as a test purchase, and due to serving other people it took me a little while to notice, but I did and I removed it when they couldn't produce ID.
I've also asked the person I'm serving for ID for anyone they are buying alcohol for and refused that drink if the ID can't be produced. Large groups of young people and the two with ID will usually result in me only serving 2 alcoholic drinks until I see ID for everyone who wants an alcoholic drink.
If I'm the one taking the risk then I'm the one who makes the decision.
And have you never seen a thread on here where someone has been asked for ID and didn't have any and were refused? There's usually hell on with people saying derogatory things about shop assistants, making up laws and licence conditions as they go along and the general feeling is that nothing, not even licencing conditions or laws, or the possibility of a fine/punishment for the person selling it, should come before customer service.
You don't have to actually break the law to break licencing conditions and face those concequences is something some people find very hard to get their head around.