The structure is correct. It would make more sense to say, "If I have a baby BOY, I will name HIM Peter" (because if your baby is a girl, presumably you won't name her Peter). You could also say 'call' instead of 'name'. I'd say 'call' is more commonly used in this sense.