Let manifold $S$ (connected, without boundary) have next property: for every submanifold $D \subset S$ (connected, compact, without boundary), every homeomorphism $f:D \to D$ extends to a homeomorphism $g: S \to S$.  

What do we know about these manifolds? Can they have dimension 3, for example? For instance, we can assume $S = \mathbb{R}, \mathbb{R}^2, S,S^2$ (line, plane, circle, 2-sphere) and we cannot assume $S = \mathbb{R}^3$. 



Manifolds such that every homeomorphism of a submanifold to itself extends to the full manifold
I seem to have misunderstood the question. I left my original answer (which answers a different question) below, and added an answer to the actual question at the top.


**Answer to the actual question:** In dimensions 3 and higher, the answer is no for topological embeddings (as asked in the question). Consider the [Alexander horned sphere](http://en.wikipedia.org/wiki/Alexander_horned_sphere) (see Rolfsen's book for a nice exposition) which for $n\geq 3$ is an embedding of $S^{n-1}$ in $S^n$ that is not locally flat at some points, and locally flat at others. A locally flat submanifold $X^k$ of $Y^n$ is one such that for every point $p\in X$ there is a neighborhood $U \subset Y$ with $(U, U \cap X) \approx (R^n,R^k)$. Let us call such a neighborhood a local product neighborhood. Alexander's original construction was in $S^3$ but the same idea works in any dimension. 


Since every $n$-manifold $M$ contains a copy of $R^n$, you can find an Alexander horned sphere in every $M$. For any two points $p,q$ on the sphere $S^{n-1}$, there is a homeomorphism $f:S^{n-1} \to S^{n-1}$ taking p to q. Embed $S^{n-1}$ in $M$ as a horned sphere, and choose $p$ to be a point where the embedding is locally flat and $q$ to be a point where the embedding is not locally flat. Then there is no homeomorphism of $M$ to itself extending $f$, because such an extension would take a product neighborhood of $p$ to a (non-existent) product neighborhood of $q$.


If you want your ambient manifold and submanifold to be smooth, then this argument doesn't work, as smooth submanifolds are automatically locally flat. In that case, you could use a non-reversible, non-amphicheiral knotted sphere of codimension $2$ as in the argument I suggested below. In that case the homeomorphism of the submanifold would be a reflection.


**Original answer**: I'm going to rename your manifold $S$ to $M$ to distinguish it from a sphere. Let's assume that your manifold $M$ has finitely generated fundamental group and dimension $n \geq 3$. This will hold if, for instance, $M$ is closed. By the [Grushko Decomposition Theorem](http://en.wikipedia.org/wiki/Grushko_theorem), $\pi\_1(M)$ decomposes as a free product of groups $A\_1\*A\_2\* \cdots A\_r\*F\_s$ where $F$ is free, and none of the $A\_i$ is cyclic or decomposes as a free product. This decomposition is unique up to permuting the factors.


Choose two knots $K$ and $K'$ in the 3-sphere such that the fundamental groups of their complements are different, and neither is isomorphic to any of the factors in the above decomposition of $\pi\_1(M)$. Then there are knots $J, J'$ in $S^n$ with such that $\pi\_1(S^n-J) = \pi\_1(S^3-K)$ and likewise for $J', K'$. Now insert these knots $J, J'$ into a ball in your manifold $M$. Then no homeomorphism $J \to J'$ will extend to a self-homeomorphism of $M$, because the fundamental groups of the two complements are different using the argument in the next paragraph. 


The fundamental group argument: $\pi\_1(M -J) = \pi\_1(M) \* \pi\_1(S^n-J)$, and likewise for $J'$. By the asphericity of knot complements in the 3-sphere, the knot groups are indecomposable with respect to free product. By the hypotheses and Grushko's theorem, any isomorphism $\pi\_1(M -J) \to \pi\_1(M -J')$ would induce an isomorphism $\pi\_1(S^n -J) \to \pi\_1(S^n -J')$, which we assume can't exist.


