While researching this question, I went to the <PERSON> page on Wiki. In the section of (the character) <PERSON>'s interests, it states that:
<PERSON>'s favorite catchphrase is "That's what she said!", a sexually suggestive double entendre he uses even in the most inappropriate circumstances, including business meetings and legal depositions. <PERSON> finds uttering the phrase so irresistible that in (the episode) "Sexual Harassment" he is goaded into saying it just seconds after <PERSON> and a lawyer from Corporate specifically ask him not to do so.
"That's what she said!", in Wikipedia, redirects to the "Said the actress to the bishop" Wiki page.
Now, as for the meaning of the phrase itself, according to the "Said the actress to the bishop" wiki page,
"Said the actress to the bishop" is an informal (and usually vulgar) exclamation, said for humour in the form of a punch line after an inadvertent double entendre. The equivalent phrase in North America is "that's what she said". Both phrases are examples of Wellerisms, a literal "turn" of a phrase, changing its meaning. 674
The versatility of the phrase and its popularity lead some to consider it a cliché.
To define "That's what she said!" as for it's use as a vulgar come-back, Wiki cites this as an example:
By 1973, "that's what she said" had already been characterized as an "ancient one-liner". In the early 1990s, it was popularized as a recurring joke in the Saturday Night Live sketch Wayne's World. In the movie of the same name, the character, <PERSON>, uses the phrase after his partner <PERSON> says, "Hey, are you through yet? 'Cause I'm getting tired of holding this," in regard to a picture he is holding.
So the joke would be: "Hey, are you through yet? 'Cause I'm getting tired of holding this", "That's what she said!", alluding to the double entendre of she was getting tired of holding his (insert male sexual body part here). :)
Now, as to why this phrase was used in the American version of "The Office",
In the original BBC version of The Office, <PERSON> character <PERSON> frequently used the phrase "as the actress said to the bishop" as an inappropriate joke. When the show was adapted for American audiences, the phrase was translated to "that's what she said" for <PERSON> character <PERSON>. "That's what she said" became a catchphrase of The Office and was used for the show's "That's What She Said" Sweepstakes.
So, it was a direct translation of essentially the British version of the same phrase used in the British Television original series upon which this series is based. 167