Since $\mathcal O_X=\mathcal O_X(0)=\mathcal O_X(D)$, we deduce $D=D-0=\operatorname{div}(f)$ for some rational function $f\in \operatorname{Rat}(X)$. But since $\operatorname{div}(f)=D$ is effective, $f$ is locally regular: there is an open covering $(U_i)$ of $X$ such that on $ U_i$ our $f$ is represented by $f_i\in \mathcal O_X(U_i)$. So actually $f$ is regular everywhere i.e. $f\in H^0(X,\mathcal O_X)$.
Since $\frac 1 f \mathcal O_X=\mathcal O_X(D)=\mathcal O_X$ it follows that the inverse $\frac 1f\in Rat(X)$ of $f$ is also regular, in other words $f\in H^0(X,\mathcal O_X^\times)$. By the definition of cartier divisors this means that$D=0$.
Edit
Cantlog attracted my attention to the fact that the implication (which I had stupidly used in a preceding version of the answer)) $H^0(X, \mathcal O_X^{\star})=k^{\star} \implies H^0(X, \mathcal O_X)=k$ is false, as shown by the counterexample $X=\mathrm{Spec} (k[T])$.
He also notices that actually you don't need the hypothesis $H^0(X, \mathcal O_X^{\star})=k^{\star} $ at all!
Many thanks to Cantlog for his great comments.