Consider the subspace of $\mathbb R^3$ given by $\widetilde X : = (S^1 + (1,0,0)) \times \mathbb Z \cup \{(0,0,z)\ |\ z \in \mathbb R \}$
and the subspace of of $\mathbb R^2$ $$X : = (S^1 + (1,0,0)) \cup (S^1 + (-1,0,0)).$$
Define a covering map $\pi : \widetilde X \longrightarrow X$ which projects down $(S^1 + (1,0,0)) \times \mathbb Z$ onto the circle $(S^1 + (1,0,0))$ and wrap the line $\{(0,0,z)\ |\ z \in \mathbb R\}$ on the other circle i.e. $S^1 + (-1,0,0).$ Consider the loop $a, b$ in $X$ defined by $a(t) = (\cos (2 \pi t) - 1, \sin (2 \pi t),0)$ and $b(t) = (1 - \cos (2 \pi t), -\sin (2 \pi t), 0)$ in $X.$ Then show that $a \ast b \not\sim b \ast a$ as based loops at $(0,0,0)$ in $X$ by showing that their lifts are not based homotopic as paths in $X.$
By the virtue of the homotopy lifting lemma it follows that if such a homotopy exists in $X$ then the unique lifts of $a \ast b$ and $b \ast a$ starting at $(0,0,0)$ in $\widetilde X$ should be fixed endpoint homotopic in $\widetilde X.$ Also I notice that $\widetilde X$ retracts to $S^1 + (1,0,0)$ just by projecting everything down to $(S^1 + (1,0,0)) \times \{0\}.$ Hence $\mathbb Z \hookrightarrow \pi_1 (\widetilde X)$ and consequently $\widetilde X$ has a non-trivial fundamental group. Will that help anyway?
Any help in this regard would be warmly appreciated.
Leaving aside my objections in the comments, I'm reasonably sure I know what you meant to say and I will proceed under that assumption. I leave some hints below to give you something to think about.
So, a basic first step is calculating these unique lifts of $ab$ and $ba$. Once you do this, you'll realise you should be thinking about the subspace: $$Y=(S^1\times\{0\}+(1,0,0))\cup((0,0)\times I)\cup(S^1\times\{1\}+(1,0,0))$$
You correctly noted $\widetilde{X}$ retracts onto each subcircle. You can think about this and observe $\widetilde{X}$ retracts onto $Y$. If $\gamma_1,\gamma_2$ denote the lifts of $ab$ and $ba$ in $Y$ (well, in $\widetilde{X}$ but their images lie in $Y$) we only need to care about showing that $\gamma_2^{-1}\gamma_1$ is not nullhomotopic in $Y$ (why?).
This is maybe silly but... $Y$ itself has a nice, easy to work with covering space, $\widetilde{Y}$ (its universal covering space is quite complicated to visualise, don't go for that one!) which looks like a ladder with evenly spaced rungs at the integers. You can compute the unique lift $\gamma$ in $\widetilde{Y}$ of $\gamma_2^{-1}\gamma_1$. $\gamma_2^{-1}\gamma_1$ is nullhomotopic in $Y$ if and only if $\gamma$ is (i) a loop and (ii) a contractible loop in $\widetilde{Y}$. It turns out $\gamma$ is a loop (when using the obvious covering map), but it should be quite clear that $\gamma$ is not nullhomotopic in $\widetilde{Y}$. Alternatively, you can choose the covering map $\widetilde{Y}\twoheadrightarrow Y$ to be such that $\gamma$ is not even a loop at all.