Yukio Matsumoto in "A 4-manifold which admits no spine", see here, constructed a compact PL $4$-manifold with boundary that is homotopy equivalent to the $2$-torus but does not deformation retract to a PL-embedded copy of $T^2$.
There are also examples of this phenomenon in higher even dimensions by Cappell and Shaneson, see here.
I do not know whether these manifolds admit topological (i.e. non PL) spines.
In codimension $\ge 3$ PL spines always exists, i.e. any homotopy equivalence from a closed PL manifold to a compact PL manifold with difference in dimensions at least $3$ is homotopic to a PL embedding. This is known as Browder-Casson-Sullivan-Wall embedding theorem.
Smooth spines exist in metastable range by Haefliger embedding theorem (roughly when the dimension of the closed smooth manifold is about $2/3$ of the dimension of the compact smooth manifold). The range is sharp, i.e. there are counterexamples with smaller codimension.