A three-year-old boy was left needing surgery after he was bitten on the face by a dog in North Ayrshire.