Spock is a character so famous for his lack of emotion and applying logic to even the most emotionally-weighted situations that TV Tropes has named this character archetype after him.
From that page (abbreviated slightly):
A character who will always think before acting, The Spock is an archetype that can be loosely summed up as the tendency to apply rules, reason and the greater good to all of his/her decisions. This character can exist by themselves, but more often, they will have a more emotional and humanistic counterpart to contrast their decisions.
The Spock's relationship with his crewmates/comrades is often tense, because this character type is willing and able to ruthlessly consider ethically troubling situations without batting an eye — especially situations where people might be ordered to die. While his counterpart The McCoy is interested in doing the right thing regardless of cost, The Spock is more interested in the end result. For him, everyone (including himself) is expendable and he has no problem treating people as such.
John calling Sherlock "Spock" is like when he calls him a "machine" - he's teasing and/or criticising him for his lack of emotion and upholding of reason and logic (in circumstances in which, in John's opinion, there are more important things than reason and logic).