There are a number of witty varieties of this verse.
The earliest reference I can find is from the periodical The Atlantic Monthly 1894 (v74 p738) which quotes -
To the astonishment of Mr. Foster, and perhaps to others of the party
inside, though all were too good-natured to laugh, the carol certainly
began : — “While shepherds washed their frocks by night, All seated on
the ground,” and then went on in stricter accordance with the
hymn-book.
The periodical "Moderator-Topics" [sic] 1902 v. 23 p. 399 has:
One little fellow, on being asked what he wished sung, replied: “While
shepherds wash their socks by night.”
A further twist in 1908:
A ram's head fixed upon a Guy was burnt on Fifth of November in the
[eighteen] 'seventies and 'eighties to the chorus of “Wild Shepherds watch their
flocks by night” for offences which had outraged the moral sense of
the inhabitants.[1]
I suspect it's much earlier though, and probably occurred to people the first time they heard it!
Edit - as a follow up (because you asked for the second pair of lines too) - we have The Homestead magazine 1923
As shepherds washed their socks by night
all seated round the tub,
the angel of the Lord came down
And taught them how to scrub.
By the 1940s we find "the angel of the Lord" has turned into "a bar of Sunlight soap", or various other varieties of soap depending on your locale.
The washing of socks is pleasing because is so closely matches the original. And so we find by the 1960 the story is expanded similar to your version. In the UK "The Lore of the Playground - 100 years of children's games, rhymes and traditions" records two varieties similar to yours in Newcastle, expanding on the washing theme (Persil, Daz and Omo are all brands of washing powder) -
While shepherds washed their socks by night
In Omo bright and blue
The angel of the Lord came down
and said: "Use Daz, it's new!"
and
While shepherds washed their socks by night
In Persil sixty-nine
The angel of the Lord came down
and said: "Those socks are mine!"
Other non-washing related British variations are recorded in the 1960s including -
While shepherds watched their flocks by night
All eating fish and chips,
The Angel of the Lord came down
And charged them two-and-six.
or
While shepherds watched their turnip tops
All boiling in the pot,
The Angel of the Lord came down
And scoffed the blooming lot.
or
While shepherds watched their flocks by night
All watching ITV,
The Angel of the Lord came down
And switched to BBC.
or
While shepherds watched their stew by night,
All bubbling in the pot,
A lump of soot came tumbling down
And spoilt the blooming lot.
- "Richmondshire: An Account of Its History and Antiquities, Characters and Customs, Legendary Lore, and Natural History, Being a Companion Volume to The Vale of Mowbray" p. 444