This expression is used in Italy when something hurts a lot.
It's an insult to a Divinity, more exactly to Mary, the mom of Jesus, comparing it to a dog.
Similar to "Madonna puttana" or "Madonna bocchinara".
It isn't suggested to say this to someone that believe in Christ.