In my experience, new mothers become very offended indeed if you say, "oh what a lovely little girl" and the child is a boy or "oh what a lovely little boy" and the child is a girl!
And asking if the baby is a son or daughter invariable provokes the offended response, "Can't you see she is a girl orhe is a boy." "no dear, I can't - I wouldn't have asked if I could."
What often works for me if in doubt is "Oh aren't you lovely, and what is your name?" Mum answers of course since the infant can't and most of the time the name is a giveaway. Names used by both sexes can bring that conversation to an end pretty quickly 🤣