The "God" and "Goddess" cakes have been on sale in the shop in the southeastern town of Grasse for about 15 years, but they suddenly caused a furore after a prominent anti-racism group slammed them as "injurious towards people of African origin".
The cakes are chocolate figures of a plump man and woman with pink lips and protruding genitalia, stuffed with ganache.
The CRAN anti-racism group had called last month for the cakes to be banned after a complaint from a resident, and went to court after the mayor refused to have them removed.
The court ordered the town's mayor to ensure the cakes were removed from the display immediately, with a penalty of 500 euros ($536) for each day's delay.
It also ordered the town to pay a fine of 1,000 euros to the CRAN group.
The court said the cakes showed "two people of colour in grotesque and obscene attitudes", adding they violate "human dignity, especially that of the African people or people of African descent".
When questioned by The Local when the cakes first hit headlines, the baker Tannick Tavolaro said he found the complaint absurd and firmly denied being a racist.
“At first I thought it was a joke then I read the news. It’s absurd and hurtful. These pastries have absolutely no racial connotation at all," he said.
“It’s made of chocolate mousse, which is why it’s black. The characters are little human beings, a man and woman but not a black man and a woman,” said Tavolaro
He had said he makes the cakes only on weekends, and often to order.