Assume $f$ is injective and take an arbitrary $y$ in $f(A\backslash B)$. Since $f$ is injective, there is a unique $x$ such that $f(x)=y\in f(A\backslash B)$. For this $x$ we have that $x\in A\backslash B$ so $x\in A$ and $x\not\in B$, so $f(x)\in f(A)$ and $f(x)\not\in f(B)$. Since $y$ was arbitrary, $f(A\backslash B)\subset f(A)\backslash f(B)$. (i)
Now take a $y$ in $f(A)\backslash f(B)$, so $y\in f(A)$ and $y\not\in f(B)$. Again, since $f$ is injective, there is a unique $x$ such that $f(x)=y$. So for this $x$ we have $x\in A$ and $x\not\in B$, so $x\in A\backslash B$, so $f(x)=y\in f(A\backslash B)$. So $f(A)\backslash f(B)\subset f(A\backslash B)$. (ii)
Thus from (i) and (ii) we conclude that if $f$ is injective, $f(A)\backslash f(B)=f(A\backslash B)$. This establishes the forward implication($\Rightarrow$).
Now assume that $f(A)\backslash f(B)=f(A\backslash B)$ for all $A,B \in X$. Take an $f(x)=y\in f(A\backslash B)=f(A)\backslash f(B)$. Thus if $x\in A\backslash B$, then $f(x)\in A$ and $f(x)\not\in B$. (iii)
Now assume that $f$ is not injective. Then there exist $x_1,x_2\in X$ such that $f(x_1)=f(x_2)$. Choose disjoint sets $A,B$ such that $x_1\in A$ and $x_2\in B$. Then we have from (iii) that for $x_1\in A$ so $x_1\not\in B$ (because $A$ and $B$ are disjoint) that $y=f(x_1)\in f(A\backslash B)=f(A)\backslash f(B)$. So $y\not\in f(B)$. This is contradiction since we assumed that $f(x_1)=f(x_2)$ and since $x_2\in B$, $f(x_2)\in f(B)$, thus $f(x_1)=f(x_2)\in B$. Because assuming $f$ is not injective leads to a contradiction, $f$ must be injective.
So if $f(A)\backslash f(B)=f(A\backslash B)$, then $f$ is injective. This establishes the backward implication($\Leftarrow$).