Takin the piss is a common expression, in the territories formerly controlled by the British Empire, currently the countries listed in the Commonwealth of Nations.
It is used to express someone having fun or intentionally irritating someone in order to amass laughs, usually through the usage of exaggerated versions of the emotions, ruling the one “pissed off”.
It is hard to tell, when and where it got conceived, though it likely comes from the 19th century, the height of the Brits.
The initial form was probably the “take the mickey” cockney slang, which basically means the same as the expression in the title; to tease someone.
This version is probably connected to the term “micturition” which is a synonym for pissing. Shorten that and you get mickey.
The phrase “taking the mickey” had been noted in the 1930’s.
Following that period came World War Two, in which soldiers from all corners of the British empire were fighting a common enemy, probably making it so, that the phrase got modified to a more commonly understood shape; Taking the piss.
Today we may hear the expression from Australia to South Africa to the very heart of London.
Urban Dictionary added the term to their definitions as early as 2003.