If $E \to X$ is a rank $r$ real vector bundle, then it is classified by a map $X \to BO(r)$. The existence of an isomorphism $E \cong E_0\oplus\underline{\mathbb{R}}$ (equivalently, the existence of a nowhere-zero section of $E$), corresponds to lifting $X \to BO(r)$ through the map $BO(r-1) \to BO(r)$ induced by the inclusion $O(r-1)\hookrightarrow O(r)$. The obstructions to such a lift lie in $H^n(X; \pi_{n-1}(S^{r-1}))$ as the homotopy fiber of $BO(r-1) \to BO(r)$ is $O(r)/O(r-1) = S^{r-1}$. Moreover, the obstructions to the uniqueness of such a lift, which corresponds to the uniqueness of $E_0$ up to isomorphism, lie in $H^n(X; \pi_n(S^{r-1}))$. This allows us to conclude the following:
- If $\operatorname{rank}E > \dim X$ (the cohomological dimension of $X$), then all the obstructions to existence vanish, so $E \cong E_0\oplus\underline{\mathbb{R}}$ for some $E_0$ with $\operatorname{rank}E_0 = \operatorname{rank}E - 1$.
- If $\operatorname{rank}E > \dim X + 1$, then all the obstructions to uniqueness also vanish, so $E \cong E_0\oplus\underline{\mathbb{R}}$ and $E_0$ is unique up to isomorphism.
In particular, if $M$ is an $n$-dimensional smooth manifold with stably trivial tangent bundle, then $TM\oplus\underline{\mathbb{R}}^m \cong \underline{\mathbb{R}}^{n+m}$ for some $m \geq 0$. If $m \geq 2$, then $\operatorname{rank}(TM\oplus\underline{\mathbb{R}}^m) > \dim M + 1$, so there is a unique vector bundle $E_0$ up to isomorphism with $TM\oplus\underline{\mathbb{R}}^m \cong E_0\oplus\underline{\mathbb{R}}$. Now note that $TM\oplus\underline{\mathbb{R}}^m = (TM\oplus\underline{\mathbb{R}}^{m-1})\oplus\underline{\mathbb{R}}$ and $TM\oplus\underline{\mathbb{R}}^m \cong \underline{\mathbb{R}}^{n+m} \cong \underline{\mathbb{R}}^{n+m-1}\oplus\underline{\mathbb{R}}$, so by uniqueness, we have $TM\oplus\underline{\mathbb{R}}^{m-1} \cong \underline{\mathbb{R}}^{n+m-1}$. After finitely many applications of this argument, we see that $TM\oplus\underline{\mathbb{R}}$ is trivial - that is, $k = 1$ unless $M$ is parallelisable, in which case $k = 0$. More generally, if $E \to X$ is a stably trivial bundle with $\operatorname{rank}E = \dim X$, then $k = 1$ unless $E$ is trivial, in which case $k = 0$.
If $E \to X$ is stably trivial and $\operatorname{rank}E < \dim X$ then it is possible that a larger value of $k$ is needed. Such examples can be constructed as in this answer. First note that $TS^n$ is non-trivial for $n \neq 1, 3, 7$. On the other hand, if $n$ is odd, then $TS^n \cong E_0\oplus\underline{\mathbb{R}}^{\rho(n+1)-1}$ where $\rho(n+1)$ denotes that $(n+1)^{\text{st}}$ Radon-Hurwitz number: if $n + 1 = 2^{4a+b}c$ where $a \geq 0$, $0 \leq b \leq 3$, and $c$ is odd, then $\rho(n+1) = 8a + 2^b$. Therefore $E_0\oplus\underline{\mathbb{R}}^{\rho(n+1)} \cong TS^n\oplus\underline{\mathbb{R}} \cong \underline{\mathbb{R}}^{n+1}$; i.e. for the vector bundle $E_0$, the value of $k$ is $\rho(n+1)$.