The statement is false in general. Let $X$ be an uncountable set with the cocountable topology. Then all the countable subsets of $X$ have the discrete topology and are therefore closed but not compact, so the only compact subsets of $X$ are the finite subsets, which also carry the discrete topology. It follows that every function $X \to Y$, where $Y$ is any topological space, is continuous on compact subsets of $X$. (But, for example, if $Y$ has the same underlying set with the discrete topology, the "identity" function $X \to Y$ is not continuous.)
Edit: In response to your second question, the property you are looking at is equivalent to being compactly generated. A topological space $X$ is compactly generated if it satisfies the following condition: a subset of $X$ is open if and only if its intersection with every compact subset is open.
So why are metric spaces compactly generated? Recall that a space is first-countable if every point has a countable neighborhood basis. Metric spaces are first-countable because at any point the sequence of open balls of radius $\frac{1}{n}, n \in \mathbb{N}$ forms a countable neighborhood basis. And first-countable spaces are always compactly generated; see the proof here.