Thagard (2012) contains a nicely compact passage on thought experiments:
Grisdale’s (2010) discussion of modern conceptions of water refutes a highly influential thought experiment that the meaning of water is largely a matter of reference to the world rather than mental representation. Putnam (1975) invited people to consider a planet, Twin Earth, that is a near duplicate of our own. The only difference is that on Twin Earth water is a more complicated substance XYZ rather than H2O. Water on Twin Earth is imagined to be indistinguishable from H2O, so people have the same mental representation of it. Nevertheless, according to Putnam, the meaning of the concept water on Twin Earth is different because it refers to XYZ rather than H2O. Putnam’s famous conclusion is that “meaning just ain’t in the head.”
The apparent conceivability of Twin Earth as identical to Earth except for the different constitution of water depends on ignorance of chemistry. As Grisdale (2010) documents, even a slight change in the chemical constitution of water produces dramatic changes in its effects. If normal hydrogen is replaced by different isotopes, deuterium or tritium, the water molecule markedly changes its chemical properties. Life would be impossible if H2O were replaced by heavy water, D2O or T2O; and compounds made of elements different from hydrogen and oxygen would be even more different in their properties. Hence Putnam’s thought experiment is scientifically incoherent: If water were not H2O, Twin Earth would not be at all like Earth. [See also Universal Fire. --Luke]
This incoherence should serve as a warning to philosophers who try to base theories on thought experiments, a practice I have criticized in relation to concepts of mind (Thagard, 2010a, ch. 2). Some philosophers have thought that the nonmaterial nature of consciousness is shown by their ability to imagine beings (zombies) who are physically just like people but who lack consciousness. It is entirely likely, however, that once the brain mechanisms that produce consciousness are better understood, it will become clear that zombies are as fanciful as Putnam’s XYZ. Just as imagining that water is XYZ is a sign only of ignorance of chemistry, imagining that consciousness is nonbiological may well turn out to reveal ignorance rather than some profound conceptual truth about the nature of mind. Of course, the hypothesis that consciousness is a brain process is not part of most people’s everyday concept of consciousness, but psychological concepts can progress just like ones in physics and chemistry. [See also the Zombies Sequence. --Luke]
I think many of the other commenters have done an admirable job defending Putnam's usage of thought experiments, so I don't feel a need to address that.
However, there also seems to be some confusion about Putnam's conclusion that "meaning ain't in the head." It seems to me that this confusion can be resolved by disambiguating the meaning of 'meaning'. 'Meaning' can refer to either the extension (i.e. referent) of a concept or its intension (a function from the context and circumstance of a concept's usage to its extension). The extension clearly "ain't in the head" but the intension is.
The Stanford Encyclopedia of Philosophy article on Two-Dimensional Semantics has a good explanation of my usage of the terms 'intension' and 'extension'. Incidentally, as someone with a lot of background in academic philosophy, I think making two-dimensional semantics a part of LessWrong's common background knowledge would greatly improve the level of philosophical discussion here as well as reduce the inferential distance between LessWrong and academic philosophers.
I have to say, I think Chalmers' Two-Dimensional Semantics thing is pretty awesome! Possibly presented in an overly complicated fashion, but hey.
As for Putnam, I think his point is stronger than that! He's not just saying that the extension of a term can vary given the state of the world: no shit, there might have been fewer cats in the world, and then the extension of "cat" would be different. He's saying that the very function that picks out the extension might have been different (if the objects we originally ostended as "cats" had been different) in an externalist way. So he's actually being an externalist about intensions too!