First it is important to understand what uniform continuity means in a topological space $X$. In its full generality, one needs a uniform structure on $X$ to speak of uniform continuity, but let's stick to an easier concept ; a topological abelian group $X$ is an abelian group in which the operation $+$ is continuous as a function $+ : X \times X \to X$ (when $X \times X$ is equipped with the product topology).
Saying that $f : X \to \mathbb R$ is continuous in this context means that for every $\varepsilon > 0$ and for all $x \in X$, there exists $U_x \subseteq X$ open such that $x - y \in U_x$ implies $|f(x) - f(y)| < \varepsilon$.
Saying that $f : X \to \mathbb R$ is uniformly continuous in this context means that for every $\varepsilon > 0$, there exists $U \subseteq X$ open such that $x - y \in U$ implies $|f(x) - f(y)| < \varepsilon$, i.e. the open set $U$ does not depend on $x$ anymore.
If we take an arbitrary abelian group $X$ and equip it with the trivial topology (all its subsets are open), then of course this turns $X$ into a topological abelian group.
Take an arbitrary function $f : X \to \mathbb R$. Taking $U = \{0\}$ (where $0 \in X$ is the neutral element for addition), we see that $f$ is uniformly continuous, hence continuous. If the abelian group is infinite, the open cover that consists of a singleton for each point does not admit a finite subcover. More formally,
$$
X = \bigcup_{x \in X} \{ x \}
$$
is an open cover of $X$ which does not admit a finite subcover because $X$ is not finite. Therefore $X$ satisfies the property that every function $f : X \to \mathbb R$ is continuous, but $X$ is not compact.
Added : Even if $X \subseteq \mathbb R^n$ to put yourself in the context where compact is equivalent to closed and bounded, your guess is still wrong. Take $n = 1$ and see that as a subset of $\mathbb R$, $\mathbb Z$ is still endowed with the discrete topology, so that the proof above applies.
Hope that helps,
I found a lot of stuff about the subject, so this answer will be rewritten too.
It seems the following.
We can answer your question positively via the following Proposition 1. Nevertheless, I am still thinking about another characterization, which will tell us more about a structure of the space $X$. We shall need the following definitions.
A subset $A$ of a metric space $(X,\rho)$ is uniformly discrete, if there exists $\delta>0$ such that $\rho(x,y)>\delta$ for each different points $x,y\in A$. It is easy to check that a metric space $X$ is totally bounded iff $X$ contains no infinite uniformly discrete subset. In particular, each unbounded metric space $(X,\rho)$ contains a uniformly discrete subset $A=\{a_n\}$, which can be constructed by induction: pick as $a_0$ an arbitrary point of the space $X$ and for each $n$ pick as $a_n$ an arbitrary point of the space $X$ such that $\rho(a_n,a_m)\ge 1$ for every $m<n$.
A metrizable topological space $Y_0$ is called an absolute extensor, abbreviated AE, provided that for every metrizable topological space $X$ and every closed subspace $A\subset X$, every continuous function $f_0:A\to Y_0$ can be extended over $X$. In particular, by Tietze extension theorem, the real line endowed with the standard metric is an absolute extensor.
Proposition 1. Let $X$ be a metric space and $Y_0$ be a metric AE-space, which is not totally bounded. The following conditions are equivalent:
Each continuous function from the space $X$ to the space $Y_0$ is uniformly continuous.
Each continuous function from the space $X$ to an arbitrary metric space $Y$ is uniformly continuous.
Each closed discrete subset of the space $X$ is uniformly discrete.
Proof. Implication $(2 \Rightarrow 1)$ is trivial. Denote the metric of the space $X$ as $\rho$, the metric of the space $Y$ as $\sigma$, and the metric of the space $Y_0$ as $\sigma_0$.
$(1 \Rightarrow 3)$. Assume the converse. Then the space $X$ contains a closed discrete subset $A_0$ which is not uniformly discrete. Then for each $n$ there are points $x_n, y_n\in A_0$ such that $\rho(x_n,y_n)<1/n$. Put $A=\{x_n : n\in\Bbb N\}\cup \{y_n : n\in\Bbb N\}$. Since the space $Y_0$ be a not totally bounded, it contains an infinite uniformly discrete subset $B$. So there is an injective map $f_0:A\to B$. Since the set $A_0$ has the discrete topology, the function $f_0$ is continuous. Since the set $B$ is uniformly discrete, there exists $\varepsilon>0$ such that $\sigma_0(x,y)>\varepsilon$ for each different points $x,y\in B$. Thus $\rho(x_n,y_n)<1/n$ but $\sigma_0(f_0(x_n), f_0(x_n))> \varepsilon$ for each $n$. Therefore the function $f_0$ is not uniformly continuous. Since the space $Y_0$ is an absolute extensor and the set $A$ is closed in the space $X$ there exists a continuous function $f:X\to Y_0$ such that $f|A=f_0$. Clearly, that the function $f$ is not uniformly continuous.
$(3 \Rightarrow 2)$. Assume the converse. Then there are a metric space $Y$ and a continuous function $f$ from the space $X$ to the space $Y$ which is not uniformly continuous. This means that there exists a number $\varepsilon>0$ such that for each $n$ there are points $x_n, y_n\in A$ such that $\rho(x_n,y_n)<1/n$ but $\sigma(f(x_n),f(y_n))>\varepsilon$. Put $A=\{x_n : n\in\Bbb N\}\cup \{y_n : n\in\Bbb N\}$. Since the function $f$ is continuous, a set $A$ has no limit points. Hence the set $A$ is closed and discrete. But the construction of the set $A$ implies that it is not uniformly discrete, a contradiction. $\square$
We shall call a metric space $X$, satisfying the equivalent conditions of Proposition 1, a fine metric space.
In the following I shall try to investigate a structure of fine metric spaces, necessary and sufficient conditions for a metric space to be fine.
Proposition 2. Each compact metric space is fine.
Proof. Let $X$ be a compact metric space and $A$ be a closed discrete subset of the space $X$. Since a closed discrete subset of a compact space is a compact and discrete space, and, hence, finite, the set $A$ is finite, and, therefore, uniformly discrete. Thus, by Proposition 1.(3), the space $X$ is fine. $\square$.
As a corollary we obtain Theorem 4.3.32 from “General Topology” by Ryszard Engelking, which has a different proof, based on the Lebesgue covering theorem:
Corollary 1. Every continuous map $f: X\to Y$ of a compact metrizable space to a metrizable space $Y$ is uniformly continuous with respect to any metrics $\rho$ and $\sigma$ on the spaces $X$ and $Y$ respectively.
Proposition 3. Each fine metric space is complete.
Proof. Assume the converse, that is a fine metric $X$ space is not complete. Then there exists a non-convergent Cauchy sequence $A\subset X$. It is easy to check that the set $A$ has no limit points, thus it is closed and discrete in the space $X$, a contradiction. $\square$.
Proposition 4. A discrete metric space $X$ is fine iff $X$ is uniformly discrete. $\square$
Proposition 5. A closed subspace of a fine metric is fine. $\square$
To be continued ....
Best Answer
Let $K$ be a compact metric space such that $X \subseteq K$. Suppose $X$ is not compact, then $X$ is not closed in $K$, hence there is a point $k \in \bar X \setminus X$. Consider the function $$ f \colon X \to \mathbb R, \quad x \mapsto \frac 1{d(x,k)} $$ ($d$ denoting the metric of $K$). Then $f$ is continuous, but not uniformly continuous, as in the letter case, $f$ would have a continuous extension to $\bar X$, which is impossible.