The attack took place in the capital's eastern area of Zayouna, where a number of brothels are located.
An interior ministry official said the gunmen burst into the establishment early in the afternoon and opened fire.
Both prostitution and alcohol are prohibited by Islam, the religion of the vast majority of Iraq's population.
Zayouna is an upmarket, mixed district of Sunni and Shiite Muslims where a number of brothels opened in the relatively quiet recent years.
Violence in Iraq has fallen from its peak in 2006 and 2007, but attacks remain common. More than 200 people have been killed in each of the first five months of this year.