The issue is that you've violated the one definition rule. In main.C, you've included Foo.H but not Foo.C (which makes sense since it's a source file). When main.C is compiled, the compiler doesn't know that you've specialized the template in Foo.C, so it uses the generic version (that returns 6) and compiles a Foo class. Then when it compiles Foo.C, it sees a full specialization which it can compile right away -- it doesn't need to wait for it to be instantiated somewhere because all the types are filled in (if you had two template parameters and only specialized one this wouldn't be the case), and it compiles a new and distinct Foo class.
Normally, multiple definitions for the same thing cause a linker error. But template instantiations are "weak symbols", which means that multiple definitions are allowed. The linker assumes all definitions are really the same and then picks one at random (well, probably consistently the first one or the last one, but only as a coincidence of the implementation).
Why make them weak symbols? Because Foo might be used in multiple source files, each of which is compiled individually, and each time Foo is used in a compilation unit a new instantiation is generated. Normally, these are redundant, so it makes sense to throw them away. But you've violated this assumption, by providing a specialization in one compilation unit (foo.C) but not the other (main.C).
If you declare the template specialization in Foo.H, then when main.C is compiled it not generate an instantiation of Foo, thus making sure only one definition exists in your program.