The unnamed Auckland waitress made the allegation in an anonymous column on left-wing website thedailyblog.Co.Nz, saying the conservative leader's actions reduced her to tears.
She said Key persisted in tugging her hair on at least half a dozen separate occasions, even though she had clearly signalled her displeasure and even warned his security detail she would punch him if he continued.
At one point, Key's wife Bronagh told him to "leave the poor girl alone", the woman wrote, saying that the prime minister gave the impression "that he just didn't care".
The waitress said Key eventually got the message and apologised to her by dropping off two bottles of wine late last month, telling her he had not realised how much she disliked his behaviour.
More From This Section
"Really?! That was almost more offensive than the harassment itself," she wrote.
Key's office said the 53-year-old, who won a third term last November and maintains a strong lead in opinion polls, had said sorry to the waitress.
"It's a familiar cafe he regularly visits with Bronagh and both have a good relationship with those who work there," a spokeswoman said.
Green Party co-leader Metiria Turei described Key's behaviour as "weird".
"New Zealanders know you can't walk into a cafe and start tugging on someone's hair, especially if they've told you they don't like it," she told Fairfax New Zealand.
"John Key should be held to the same standards as the rest of us.