Generally small numbers (1-10 or 20) are by tradition written as words and anything else as digits. I have seen both limits recommended, so the 11-20 group could be seen as optional. ;-)
I agree with TDOL's answer. The most common "rules" I have seen state that 1-10 or 1-12 should be written out. There are also style guides that add that if there is a combination, the two forms shouldn't be mixed.
John has two cats.
John has 17 birds.
John has 2 cats and 17 birds.