A 12-year-old child is 12 years old. That is, when the adjectival phrase (12-year-old) comes before the noun it modifies (child), it is hyphenated, and it is unhyphenated when it comes after the noun it modifies. This is the standard practice for phrasal adjectives of all kinds, not just those relating to age. For example, the phrasal adjective is hyphenated in the clause he has a larger-than-life personality, but not in his personality is larger than life.
Similar age phrases are also hyphenated when they function as nouns. The 12-year-old child is a 12-year-old.
In most contexts, the numbers one through ten are spelled out (though some publishers only spell out one through nine) and all numbers 11 and up are written as numerals. This practice applies to ages. For example, one might write, “The 30-year-old man had two children, a seven-year-old and a 12-year-old.”