Of course, std::swap would be the right thing to do here, as GMan pointed out. But let me explain the problem with your code:
string tmpStr("ab");
const char& tmpChar = tmpStr[0];
tmpStr[0] = tmpStr[1];
tmpStr[1] = tmpChar;
tmpChar is actually a reference to tmpStr[0]. So, this is what will happen:
| a | b | (initial content, tmpChar refers to first character)
| b | b | (after first assignment)
Note, that since tmpChar refers to the first character, it now evaluates to 'b' and the second assignment does effectivly nothing:
| b | b | (after second assignment)
If you remove the & and make tmpChar an actual character variable, it'll work.