Let $M$ be a smooth manifold (with boundary). Suppose I have a smooth vector field $T$ defined on the complement of a compact subset $K$ of $M$ and I wish to extend $T$ to the whole of $M$. What are the obstructions to doing so? Does $M$ need to be compact? Does $K$ need to be a submanifold?


I have a feeling that an argument involving a partition of unity of $K$ would suffice for extending $T$ into $K$, but have not been able to find a decent reference.



Extensions of local vector fields to whole manifold
The sheaf of smooth functions on a manifold is [fine](https://ncatlab.org/nlab/show/fine+sheaf) and hence [soft](https://ncatlab.org/nlab/show/soft+sheaf), so we can extend sections on closed subsets to global sections. However, it is not generally [flabby (flasque)](https://ncatlab.org/nlab/show/flabby+sheaf): local sections on open subsets do not in general extend to global sections. Note that only discrete manifolds can have a flabby sheaf of smooth functions, which is the case because every subset is open and hence closed.


Modules over the sheaf of smooth functions are also soft, but not in general flabby (except for the zero module, for trivial reasons). Since the sheaf of vector fields is such a module, we wouldn't usually expect vector fields on open subsets to extend to global sections.


For example, if you have any sort of open (proper) subset which is diffeomorphic to an open ball, just take a smooth function that blows up as you go to the boundary of the ball. Then you can rescale any vector field that does not decay to zero at the boundary to a vector field which fails to globalize.


H. H. Rugh's example in his answer is also very good because it shows that even without blow ups, a smooth vector field on an open set (which in his case is diffeomorphic to an open disk) can fail to extend globally due to the topology of the sphere.


As mentioned by Ben McKay in the comments, you can have a look at Charles Fefferman's paper proving a sharp version of the Whitney extension theorem. It's available [here](http://web.math.princeton.edu/facultypapers/Fefferman/SharpFormWhitneyPaper.pdf).


