At least in Texas, it's illegal just to ask, as long as the interviewee did not bring the topic up.
It is very common for confused employers to claim it is illegal, but as eli described this is an oversimplification and is not actually true.
Don't get me wrong, it is a very bad idea to ask these questions. But it is not illegal, strictly speaking.
Though of course you should still avoid asking questions about someone's protected status!