You can tell xspace not to add a space before \Tt with
\xspaceaddexceptions{\Tt}
As pointed out in the comments by David Carlisle this will stop xspace from adding space before \Tt in all situations, even if you would otherwise like to see it, say because you have
\newcommand\study{\study\xspace}
and then
We \study \Tt.
(David's example.)
Since it has been brought up in comments under the question and under the answer, let me also mention in this answer that it would be preferable not to use \ensuremath and \xspace in this situation at all. Forcing yourself into math mode where math mode is appropriate has the advantage that you probably won't write something like \Tt - \Tt in text mode, which is nearly always not what you wanted. You might save a few keystrokes, but you lose clarity and run the risk of producing unfortunate constructions like \Tt - \Tt. Plus if you are forced to use math mode, the issue with macros eating the following space goes away... For reasons not to use xspace see also Drawbacks of xspace, for \ensuremath there is When not to use \ensuremath for math macro?.
I strongly recommend you use the \Ttm in the example below, i.e. no \xspace and no \ensuremath.
\documentclass{article}
\usepackage{xspace}
\newcommand{\Tt}{\ensuremath{t}\xspace}
\xspaceaddexceptions{\Tt}
\newcommand{\Ttm}{t}
\begin{document}
We study \Tt pairs.
We study $\Ttm$ pairs.
We study \Tt\Tt pairs.
We study $\Ttm\Ttm$ pairs.
\end{document}
xspaceis not an acceptable answer, you may want to try\xspaceaddexceptions{\Tt}. – moewe Nov 10 '18 at 14:30\Ttin\xspaceaddexceptions{\Tt}disappeared. – Viesturs Nov 10 '18 at 14:32We study $t$ as a single item and $tt$ as a pair?\Ttis three keys as well as $t$,\Tt\Ttis six instead of four. Even if you want to define a command (and there are good reasons to),$\Tt$is way clearer and less error prone than using\ensuremath. – egreg Nov 10 '18 at 14:33\Ttin\xspaceaddexceptions{\Tt}disappeared."? The command should be used once in the preamble to avoid\xspaceadding the unnecessary space before\Tt. You are not supposed to use it instead of\TtinWe study \Tt as single items.. – moewe Nov 10 '18 at 14:35\xspaceaddexceptions{\Tt}in preamble works. Will you supply an answer? – Viesturs Nov 10 '18 at 14:37\Ttis heavily used in the document and it should be differentiated from$t$'s not having the same meaning as\Tt. And I simplify my examples. Imagine,$t^{3}_{a}$. – Viesturs Nov 10 '18 at 14:40\newcommand{\Tt}{t}(so that you can change your mind later about how to represent the object). There is no good reason for using\ensuremath. – egreg Nov 10 '18 at 14:50\xspace(sometimes I regret publishing that package at all:-) – David Carlisle Nov 10 '18 at 18:02\xspaceisn't useful, it is much simpler to add the space when you need one, than try to tune its automatic guess of when a space is needed. – David Carlisle Nov 10 '18 at 22:30