Green’s Dictionary of Slang

pain (in the neck) n.1

also pain in the head, ...side

1. [late 19C+] a feeling of irritation; see give someone a pain in the neck

2. [1910s+] an annoying person, a bore, a euph. for pain in the arse n.

3. an annoying situation, anything considered unpleasant, typically a task one does not wish to perform.

4. (Aus.) a general insult.

In phrases

give someone a pain in the neck (v.) (also give someone an ache, ...a pain in the ear, ...face, ...guts, ...teat)

[late 19C+] of a person, thing or situation, to irritate someone.