Let $M_{\beta }$ be the fractional maximal function. The commutator generated by $M_{\beta }$ and a suitable function $b$ is defined by $[M_{\beta },b]f = M_{\beta }(bf)-bM_{\beta }(f)$. Denote by $\mathscr {P}(\mathbb R^{n})$ the set of all measurable functions $p(\cdot )\colon \mathbb R^{n}\to [1,\infty )$ such that $$ 1< p_{-}:=\mathop {\rm ess inf}_{x\in \mathbb R^n}p(x) \quad \text {and}\quad p_{+}:=\mathop {\rm ess sup}_{x\in \mathbb R^n}p(x)<\infty , $$ and by $\mathscr {B}(\mathbb R^{n})$ the set of all $p(\cdot ) \in \mathscr {P}(\mathbb R^{n})$ such that the Hardy-Littlewood maximal function $M$ is bounded on $L^{p(\cdot )}(\mathbb R^{n})$. In this paper, the authors give some characterizations of $b$ for which $[M_{\beta },b]$ is bounded from $L^{p(\cdot )}(\mathbb R ^{n})$ into $L^{q(\cdot )}(\mathbb R^{n})$, when $p(\cdot )\in \mathscr {P}(\mathbb R^{n})$, $0<{\beta }<n/p_{+}$ and $1/q(\cdot )=1/p(\cdot )-\beta /n$ with $q(\cdot )(n-\beta )/n \in \mathscr {B}(\mathbb R^{n})$.