There is no way of enforcing such a law except post-factum. Basically, if a woman drinks and smokes at such a level that it endagers the child, when the child will be born and tests will be made, it will be detectable if the woman behaved irresponsably while she was pregnant, and yes, if she did harm the child through her behavior, she should be prosecuted.
However, there is no way of making a law that states that it is illegal for women who are pregnant to smoke and drink. I mean, if you make it... you can't possibly enforce it and it will just, most likely, backfire.
What you can do is create, what we have created, a culture that encourages and applauds women who behave responsibly towards their unborn children and discourages reckless behavior.
And if we are talking about the society way of dealing with problems, men, when trying to have children with their spouses, should also quit smoking.