A very closely related question (and maybe the one you meant to ask?) is: which spaces $Y$ in the category of topological spaces and continuous maps are exponentiable, i.e., for which $Y$ does the functor $- \times Y: Top \to Top$ have a right adjoint? A necessary and sufficient condition is that $Y$ is core-compact, as defined at the nLab. See also the references in that article.
There are various ways of defining core-compactness; perhaps the fastest is that the topology is a continuous lattice. It is a slightly weaker condition than local compactness (if local compactness is defined as meaning that every point has a basis of compact neighborhoods), and coincides with local compactness if $Y$ is Hausdorff.
If $Y$ and $Z$ are core-compact, then for every $X$ one can exhibit a canonical homeomorphism
$$(X^Z)^Y \cong X^{Y \times Z}$$
by abstract nonsense (since any two right adjoints to $- \times (Y \times Z)$, in particular $((-)^Y)^Z$ and $(-)^{Y \times Z}$, are canonically naturally isomorphic).
Your question is also interesting when interpreted for locales. See Johnstone's Stone Spaces, where it is shown that a locale is exponentiable if and only if it is locally compact.
If $Y$ is not core-compact, then it is possible to show that there is no exponential $\mathbf{2}^Y$ where $\mathbf{2}$ is Sierpinski space (two points, one open, one closed). In other words, the functor $\hom_{Top}(- \times Y, \mathbf{2})$ is not representable. I once went through the detailed argument (in the case where $Y$ is the space of rational numbers, which I think is illustrative) over at the n-Category Café, see here and the ensuing discussion.