Sgt James Harrison was attacked at Adsa in Dudley's High Street on Tuesday night at around 8.20pm.
The 19-year-old woman was detained.
A spokesman for West Midlands Police said: "The woman has been sectioned under the mental health act."
The 39-year-old officer was taken to hospital where he was checked over but is now recovering at home.
Ch Spt Steve Graham, Head of Force Response, added: “I am proud of the actions and bravery of Sgt Harrison and his team.
“The selfless quick action taken by the team to protect the public from being hurt is an exceptional piece of police work and their actions demonstrate outstanding courage.”
Sgt Harrison thanked everyone for their messages of support.
He said on Twitter: "Just want to say thank you for all the messages of support I have received."
An Asda spokesman said: "We're assisting police with their enquiries."