Let $X$ be a $n$-dimensional dimensional CW-complex and $\pi_k(X)=0$ for $ n \ge k >1$. Therefore obviously by construction every attaching map $f_i^k: S^k \to X^{(k)}$ of a $(k+1)$-cell $e_i^{k+1}$ is homotopic to constant map.
What are the weakest conditions such that the $k+1$-skeleton $X^{(k+1)}$ which is inductively constructed as pushout
$$X^{(k+1)} := X^{(k)} \coprod_{f_i^k: S^k \to X^{(k)}} (\coprod_i D^{k+1})$$
is homotopic to
$$(X^{(k+1)})':=X^{(k)} \coprod_{c_i^k \in X^{(k)}} (\coprod_i D^{k+1}) = X^{(k)} \bigvee_i S^k $$
where $c_i^k \simeq f_i^k: S^k \to X^{(k)}$ are the constant maps homotopic to attaching maps $f_i^k$ with resepect the $(k+1)$-cells $e_i^{k+1} \cong D^{k+1}$.
More generally, what are the weakest conditions under which if $X,Y,Z$ are CW-complexes $X \subset Y$ is an inclusion (as sub CW complex, and therefore a cofibration) and $f: X \to Z$ homotopic to constant map $c $, then the pushout $Y \coprod_{f, X} Z$ is homotopic to $Y/X \coprod_c Z = Y/X \vee_c Z$.
The question is motivated by this counterexample showing that it's not always possible to kill certain $k$-homology classes by attaching $(k+1)$-cells.
Let me answer the "More generally" question. No extra conditions are needed. If $j\colon X\rightarrow Y$ is a cofibration and $f,g\colon X\rightarrow Z$ are homotopic maps, then $Y\cup_fZ$ and $Y\cup_gZ$ are homotopy-equivalent rel $Z$. The spaces need not be CW-complexes for this. Note that if $g$ is constant with value $z$, the attaching space $Y\cup_gZ=Y/X\vee Z$ (wedged together at $X/X$ and $z$). An elementary discussion of this can be found in Hatcher's Algebraic Topology, Proposition 0.18 (he states it only for CW pairs, but that is not necessary). For more abstract perspectives, this also follows from Theorem 5.1.9 or Proposition 5.3.4 in tom Dieck's Algebraic Topology.
However, I do not believe this "More generally" question is actually a generalization of what you ask before. The condition that $\pi_k(X)=0$ does not imply $\pi_k(X^{(k)})=0$, so it is not true that the attaching maps $S^k\rightarrow X^{(k)}$ are homotopic to constant maps. For example, take $X=D^2$, which is even contractible, but the attaching map $\mathrm{id}\colon S^1\rightarrow S^1$ of the $2$-cell is not homotopic to a constant as $S^1$ is not contractible.