Claim: If $X$ is locally compact Hausdorff, then a subset $A\subseteq X$ is locally compact in the subspace topology if and only if it is locally closed.
Here a subset $A$ is locally closed if it is open in its closure $\overline A$. Equivalently if $A$ is the intersection $U\cap C$ of an open subset $U\subseteq X$ and a closed subset $C\subseteq X$.
Proof of claim: $\Rightarrow$ Suppose $A$ is locally compact. To show that it is locally closed in $X$ it will suffice to show that each point $x\in A$ has an open neighbourhood $U\subseteq X$ such that $U\cap\overline A\subseteq A$. Proceed as follows. Since $A$ is locally compact there is a compact $K\subseteq A$ and an open $U\subseteq X$ such that $x\in U\cap A\subset K\subset A$. Then $K$ is also compact in $X$, and hence closed there too, since $X$ is Hausdorf. Thus $\overline{U\cap A}\subset K\subset A$. Now notice that $U\cap\overline A\subseteq \overline{U\cap A}$. For if $y\in U\cap\overline A$ and $V$ is any neighbourhood of $y$, then $U\cap V$ is a a neighbourhood of $y$, which therefore meets $A$, so $V\cap(U\cap A)=(U\cap V)\cap A\neq\emptyset$ and hence $x\in \overline{U\cap A}$. Thus we have $x\in U\cap \overline A\subset \overline{U\cap A}\subseteq A$, as required.
$\Leftarrow$ The subset $\overline A$ is locally compact as it is closed in the locally compact space $X$. Thus if $A$ is an open subset of $\overline A$, then $A$ is also locally compact. $\square$
Remarks: The first part of the proof establishes that any locally compact subspace of a Hausdorff space $X$ is locally closed (regarless of whether $X$ itself is locally compact). The second part of the proof establishes that any locally closed subset of a locally compact space is locally compact (regardless of any separation assumptions. Here the correct definition of local compactness is that each point have a base of compact neighbourhoods).
Examples: 1. Any half-open interval $[a,b)$ or $(a,b]$ is a locally compact subspace of $\mathbb{R}$ which is neither open nor closed. Since finite products of locally compact spaces are locally compact, $\prod^{n}_{i=1}[a_i,b_i)$ and $\prod^{n}_{i=1}(c_i,d_i]$ and mixed products thereof are locally compact subspaces of $\mathbb{R}^n$, and in particular locally closed there. 2. Neither $\mathbb{Q}$ nor its complement $\mathbb{P}=\mathbb{R}\setminus\mathbb{Q}$ is locally compact, since neither is locally closed in $\mathbb{R}$. Products like $\mathbb{Q}^n$ and $\mathbb{P}^n$ are not locally closed in $\mathbb{R}^n$ and are not locally compact.
Best Answer
For a different flavor of example, consider $C[0,1]$ with the uniform norm. By a standard theorem (Stone-Weierstrass), the space $P$ of polynomial functions is dense in this space. But then, since $P$ is dense but clearly not equal to the whole space, it can't be closed in it.
Most of the standard Banach spaces you know are separable - which, in practice, means that they have a "nice" dense subspace. That dense subspace is a non-closed subspace.