The Hangover actor, who played Doug in the movie and its sequel, will appear in NBC's pilot The New Normal, about a gay couple and a woman who becomes their surrogate.
Bartha will play David, while his husband Bryan will be portrayed by The Book of Mormon's Andrew Rannells.
Scottish actress Georgia King from BBC's Little Dorritt plays Goldie, the surrogate mother.
NBC won the rights to the 30-minute show following a multiple network bidding war in January.
Ali Adler - who joined Glee as a writer this season - will pen the comedy alongside Murphy, who will also direct the pilot.
The 20th Television/Ryan Murphy Productions project will be Murphy's fourth series if subsequent episodes are to be ordered.
Aside from Glee, he has found success with The Glee Project and American Horror Story.
> Justin Bartha: 'Hangover II is dirtier'
> MTV Movie Awards open with Hanover II spoof