It is also the only vitamin needed by humans that, to the best of our knowledge, can be gotten only from animals (or pills). It is produced by bacteria present in milk, eggs, and meat. (However, inactive forms of it may also be found in nutritional yeast, soy products, etc.1.) It is needed in only very small amounts -- although the RDA of 2.4 micrograms is generally accepted to be much too low; a daily allowance of 10 micrograms is probably closer to a healthy level.
B12 deficiency was originally defined as levels low enough to cause pernicious anemia. But aside from being necessary to form healthy red blood cells, B12 is also necessary to maintain the sheath surrounding and protecting nerve fibers and is necessary for cellular metabolism in every cell in your body. It is now becoming recognized that healthy levels of B12 cannot be judged on preventing anemia alone.
B12 is a co-enzyme based on cobalamin; it is common to see B12 called cobalamin, but it is important to remember that not all cobalamin is a vitamin -- that is, there are a number of B12 analogues that do not provide a benefit to your body.
Many studies have found that nearly all vegans, vegetarians, and partial-vegetarians have low B12. This begins to have measurable negative effects within one to two months of beginning this sort of diet. In the past it was believed that the body stored B12 for a decade or longer, but it has since been found that this stored B12 is not accessible for all necessary functions. B12 deficiency is also common in the elderly, people on Metformin, and those who take frequent doses of antacids (the acids in the stomach are necessary to activate the B12).
There are no significant risks to taking megadoses of B122, but generally you should be wary of anyone recommending more than 500 micrograms a day (unless they are a doctor). Even that level is generally reserved for people with a B12 deficiency; a healthy young adult should probably aim for a daily intake of about 10 micrograms a day minimum, and perhaps a 250 a day as general maximum.
Footnotes:
1. Studies have found that forms of B12 from yeast and vegetable sources are not usable by most humans. There are however, some people who seem to be able to utilize these sources. It should be noted that these sources can increase vitamin B12 serum levels without reducing some effects of B12 deficiency.
2. Reports of skin conditions have been noted, but are rare.