First, you are aware that an irreducible polynomial $f(x)$ of degree $a$ divides $x^{p^b}-x$ in $\mathbb{F}_p[x]$ iff $a \ | \ b$, right:
A question based on a n irreducible polynomial dividing $x^{q^n}-x$ in finite fields
So let $K$ be a field of cardinality $p^b$. Then for some irreducible polynomial $h(x) \in \mathbb{F}_p[x]$ of degree $b$, the field $K$ can be written as $K = \mathbb{F}_p(\alpha)$ where $\alpha$ is a root of $h(x)$,
and every element $y \in K$ can be written $y=y(\alpha)$, where $y(x)$ is a polynomial in $\mathbb{F}_p[x]$ of degree $<b$. Now, note that all $p^b$ elements $y(\alpha)$ of $K$ satisfy $y^{p^b}(\alpha) -y(\alpha) = 0$, or equivalently,
$$h(\alpha) \ | \ (y^{p^b}(\alpha) -y(\alpha)).$$ Thus for every $y(\alpha)\in K$ there is an irreducible polynomial $f(x) \in \mathbb{F}_p[x]$ that divides the polynomial $x^{p^b}-x$, that has $y(\alpha)$ as a root i.e., $h(\alpha) \ | \ f(y(\alpha))$. Note also that $p^b$ is the degree of the polynomial $x^{p^b}-x$, so the polynomial $x^{p^b}-x$ must factor completely in $K$. So conversely, for every irreducible polynomial $f(x) \in \mathbb{F}_p[x]$ that divides the polynomial $x^{p^b}-x$, there is a $y(\alpha) \in K$ such that $y(\alpha)$ is a root of $f$, i.e., $h(\alpha) | f(y(\alpha))$.
Now, let $f$ be an irreducible polynomial of degree $a$. Then as already noted near the top, $f(x)$ divides the polynomial $x^{p^b}-x$ in $\mathbb{F}_p[x]$. So then there is a $y_f(\alpha) \in K$ such that $y_f(\alpha)$ is a root of $f$. Note however as $y_f(\alpha)$ is a root of an irreducible polynomial, namely, $f$ in $\mathbb{F}_p[x]$ of degree $a$. So $y_f(\alpha)$ generates a field $F$ of precisely $p^a$ elements. As $y(\alpha)$ is in $K$, it follows that $F$ is a subfield in $K$. So if $a \ | \ b$, there is a subfield $F$ of $p^a$ elements inside a subfield $K$ of $p^b$ elements.
Note the converse by noting that every field $F$ of $p^a$ elements can be written $F=\mathbb{F}_p(\gamma)$ for some $\gamma$ that is the root of an irreducible polynomial $f(x) \in \mathbb{F}_p[x]$ of degree $a$. As also noted above then, if $\gamma$ is in $K$, then $f(x)$ must divide $x^{p^b}-x$, but as noted in the top paragraph, this does not happen unless the degree $a$ of $f(x)$, divides $b$. So here, only if $a \ | \ b$ is there a subfield of $p^a$ elements inside a subfield $K$ of $p^b$ elements.
***For the only if direction, one could also note that a field $F$ of $p^a$ elements satisfies $F^×=F \setminus \{0\}$ and is a group w exactly $p^a-1$ elements, while a field $K$ of $p^b$ elements satisfies $K^×=K \setminus \{0\}$ and is a group with $p^b-1$ elements. So $p^a-1$ must divide $p^b-1$, and this happens only if $a$ divides $b$.