Since you specified two initial conditions, I will assume you meant to solve
$$y''+y=f(t)=\begin{cases}0, &02\pi.\end{cases}$$
In preparation for Laplace transforming both sides of the equation, let's look at how to compute $\mathscr{L}\{f(t)\}$. One way is directly from the definition:
$$
\mathscr{L}\{f(t)\}=\int_0^\infty f(t)e^{-st}\,dt=\int_{\pi}^{2\pi} 1\cdot e^{-st}\,dt={1\over s}\left(e^{-\pi s}-e^{-2\pi s}\right).
$$
However, it sounds like you are curious about how to compute the transform after rewriting $f(t)$ as a combination of unit step functions. Here's how (and this might help to see how to get this form):
\begin{align}
f(t)&=u(t-\pi)-u(t-2\pi)\\
\mathscr{L}\{f(t)\}&=\mathscr{L}\{u(t-\pi)\}-\mathscr{L}\{u(t-2\pi)\}={e^{-\pi s}\over s}-{e^{-2\pi s}\over s},
\end{align}
which is of course the same result as the previous method.
Now we are ready. Laplace transforming both sides,
\begin{align}
\mathscr{L}\left\{y''+y\right\}&=\mathscr{L}\{f(t)\}\\
s^2Y(s)-sy(0)-y'(0)+Y(s)&={1\over s}\left(e^{-\pi s}-e^{-2\pi s}\right)\\
Y(s)&={e^{-\pi s}-e^{-2\pi s}\over s(s^2+1)}\\
Y(s)&={e^{-\pi s}\over s}\cdot {1\over s^2+1}-{e^{-2\pi s}\over s}\cdot {1\over s^2+1}
\end{align}
In this form, the inverse transforms on the right-hand side are readily doable via the Convolution Theorem:
\begin{align}
\mathscr{L}^{-1}\{Y(s)\}&=\mathscr{L}^{-1}\left\{{e^{-\pi s}\over s}\cdot {1\over s^2+1}-{e^{-2\pi s}\over s}\cdot {1\over s^2+1}\right\}\\
y(t)&=u(t-\pi)*\sin t-u(t-2\pi)*\sin t\\
y(t)&=\int_0^t u(\tau-\pi)\sin(t-\tau)\,d\tau -\int_0^t u(\tau-2\pi)\sin(t-\tau)\,d\tau\\
y(t)&=(1+\cos t)u(t-\pi)-(1-\cos t)u(t-2\pi).
\end{align}
Here's a plot of the input $f(t)$ (red) and the system response $y(t)$ (blue):

Hope that helps.