The solution given by your teacher is the right one. Assuming that the intial condition is given by $y(0)=y_0$ we get the following
\begin{align}
y'&=-ky+p\\
y'&=-k\left(y-\frac pk\right)\\
\frac{y'}{y-\frac pk}&=-k\\
\int \frac{\mathrm dy}{y-\frac pk}&=-k\int\mathrm dx\\
\log\left(y-\frac pk\right)&=-kx+c\\
y-\frac pk&=ce^{-kx}\\
\end{align}
$$\therefore~y(x)~=~ce^{-kx}+\frac pk$$
Determining the constant $c$ by using $y(0)=y_0$ we get
$$y(0)=c+\frac pk=y_0\Rightarrow~c=y_0-\frac pk$$
$$\therefore~y(x)=\frac pk+\left[y_0-\frac pk\right]e^{-kx}$$
I cannot really tell where you went wrong but it is easy to check that your solution does not fulfill the initial condition since
$$y(x)=y_0e^{-kx}+\frac pk\Rightarrow y(0)=y_0+\frac pk\color{red}\neq y_0$$