It's not necessary. See If $e^A$ and $e^B$ commute, do $A$ and $B$ commute?
It is known, however, that if the spectra of both $A$ and $B$ are $2\pi i$-congruence-free (i.e. if the difference of every pair of eigenvalues in $A$ is not an integer multiple of $2\pi i$, and similarly for $B$), then $e^A$ and $e^B$ commute if and only if $A$ and $B$ commute. See
Edgar M.E. Wermuth, Two remarks on matrix exponentials, Linear Algebra and Its Applications, 117(1):127-132, 1989.
Edgar M.E. Wermuth, A remark on commuting operator exponentials, Proceedings of the American Mathematical Society, 125(6): 1685-1688, 1997.
(Remark. In the first paper above, while the author has imposed the condition that the matrices have algebraic entries, this is just a sufficient condition for the matrices to have $2\pi i$ congruence-free spectra. In the second paper, the conclusion is generalised to bounded operators with $2\pi i$-congruence-free spectra on a Banach space.)
It follows that if $e^A$ and $e^B$ commute, it's almost surely true that $A$ and $B$ commute.
See also a related discussion (and loup blanc's answer in particular) on the question Is $\exp:\overline{\mathbb{M}}_n\to\mathbb{M}_n$ injective?