@DasBeasto has a point regarding security, though as far as the UX goes I've always been of the mindset that most people today can't retain more than 3 digits in their head these days. Any more and they start making mistakes or forgetting. That said, a few apps do use 3-digit lengths, numerals only, to either unlock or gain access to a particular application. And frankly that's fine, especially for two-factor authentication where your phone is the second factor.
That said, many apps and services prefer to use different counts. 4, 6, 10, alphanumeric, etc. Really it runs the gamut, and while each additional character and type of character adds to the security, it detracts from the UX and also isn't always necessary depending on how the app is built. For instance, the last app I built that used this (where we sent an SMS with a 3-digit code) had a push notification that went out in advance, once the request was sent, with the correct code (so that no one else could use it without having access to the phone).
Ultimately it depends on the specific use case (which isn't listed here), but in general three digits is safe and easy for users to remember.