There are two possibilities. If you are using it as a noun it is "two-year-old".
How many children do you have?"
"Two. A four-year-old and a two-year-old."
The other way is if two years is used as a description, telling how old the child is.
"How old is he?"
"He is two years old."
[Notice no hyphen]
If I was talking about multiple (let's say three) children who are two years old and using the noun form it would be:
"Three two-year-olds"