Gyp is a moderately common expression, mainly in the UK, but also in Commonwealth countries, though my gut feeling is that it’s now mostly used by older people. It appears in fixed phrases that refer to some part of the body being painful, as in this example from the London Evening Standard in August 2003: “I turned my ankle in the game and it’s still giving me gyp.”
The other meaning you give has no connection — it’s a derogatory term that is usually said to derive from the word gypsy. The sense of pain seems to be connected with a northern English dialect word, variously spelled gip or jip, that only ever appeared in the form “to give somebody or something jip”. It could mean to give a person or an object a sound thrashing (one example is of a man giving a carpet a beating), or generally to treat roughly or to cause pain.
We’re not certain where it comes from, but the English Dialect Dictionary gives one sense of the word as “to arouse to greater exertions by means of some sudden, unexpected action”. That fits with the suggestion in the Oxford English Dictionary that it’s a contracted form of gee-up, a conventionalised version of the cry one utters to get a horse to move. Presumably the pain sense evolved through the excessive use of that unexpected action in persuading a person or animal to do one’s bidding.
There’s also gyppy, as in gyppy tummy, a term for diarrhoea mostly known in the UK and Commonwealth countries. This does have the same origin as gypsy — a mangled version of Egyptian. Gyppy tummy is noted by Eric Partridge as World War Two services slang for the ailment suffered by British forces in the North African desert campaign, and it was a phrase common in Britain after the War. It seems certain that gyppy was influenced in its creation by the pain sense of gyp, but also built on gyppy or gippy, a slang term for an Egyptian that can be traced back to Lord Kitchener's army in Egypt in the 1880s and 1890s.