Assume we have a connected CW-complex $Y$ and $X\hookrightarrow Y$ a connected sub-complex. We know that the inclusion induces injection on all homotopy groups. Is it true (or under what conditions it can be true) that we can attach cells to $Y$ so that the inclusion induces isomorphism on homotopy groups? (This will subsequently imply that $X$ is a deformation retract of the enlarged $Y$.)


You can further more assume that the inclusion of $X$ is a map of infinite loop spaces. If that helps.
Edit: The inclusion is also injective on the homologies.



Turning injection of homotopy groups to an isomorphism
Your question is equivalent to the following: 


*Given a cellular inclusion $i : X\to Y$, when is there a retraction $r:Y \to X$?*


(Being a retraction means that $r\circ i: X\to X$ is the identity.)


The answer is usually phrased in terms of obstruction theory. 


For simplicity, let's assume that $Y$ is a finite complex obtained from $X$ by attaching a single $j$-cell, i.e., $Y = X \cup\_f D^j$, where $f: S^{j-1} \to X$ is the attaching map. Assume also that $X$ is a based space an $f$ is a based map. 


In this case, it is easy to check that the desired retraction $r: Y \to X$ exists
if and only if the homotopy class $[f] \in \pi\_{j-1}(X)$ vanishes. We can think of this class as an obstruction lying in
$$
\theta \in H^j(Y,X;\pi\_{j-1}(X))
$$
(the $j$-cohomology group of the pair $(Y,X)$ with coefficients in $\pi\_{j-1}(X)$).


Now, in the general case, we inductively assume that a
retraction $$r\_{j-1}: X\_j \cup\_{X\_{j-1}} Y\_{j-1}\to X$$ has already been specified where
 $Y\_{j-1}$ is $(j-1)$-skeleton of $Y$. We wish to 
extend the retraction to $Y\_j$. For every cell of $Y\_j$ that is not lying in $X$,
we have an obstruction in $\pi\_{j-1}(X)$ defined as above. If we vary the cells, we obtain an element of
$$
H^j(Y\_j,Y\_{j-1} \cup X\_j ;\pi\_{j-1}(X))
$$
whose vanishing is both necessary and sufficient to finding an extension $r\_j: X \cup Y\_{j} \to X$. Notice that the displayed cohomology group is the *cellular $j$-cochains* of the pair $(Y,X)$ with coefficients in $\pi\_{j-1}(X)$. It turns out that the element in question is a cocycle in this cochain complex. 


However, notice we made a choice: suppose we had used a different $r\_{j-1}$? 


Then the obstruction can change. With a little effort one can eventually see that the obstruction changes by a coboundary. So if we take into account all the choices, the cocycle is defined only up to a coboundary.


The upshot: there is a sequence of obstructions 
$$
\theta\_j \in H^j(Y,X;\pi\_{j-1}(X))
$$
such that $\theta\_j$ is defined when $\theta\_{j-1}$ vanishes. 
Furthermore all the obstructions vanish iff a retraction $Y\to X$ exists. 


