How do you tell the difference between B12 deficiency and iron deficiency anemia?

Blood work. Your physician can order commonly available tests for your levels of b12, iron, iron binding capacity and the carrier proteins for iron. All of these factors have some effect on blood cells. The direction of investigation can start with a CBC or complete blood count. Iron deficience eventually produces visably smaller blood cells while B12 deficience results in larger ones..
RBC size. I think your question is how do you distinguish between anemia caused by iron deficiency and that caused by B12 deficiency. The answer is the size if the red cells. Iron deficiency causes red cells to be smaller than normal, while B12 deficiency causes them to be larger than normal. Specific blood tests can confirm.
Your blood tests. The same blood tests that doctors run to check for anemia in a person can also give a clue as to the cause of anemia. With iron deficiency, red blood cells tend to be smaller than normal (low mcv), while in B12 deficiency the red blood cells tend to be larger (high mcv). Of course, you can also just check the iron and B12 levels directly to see what is low (another blood test).