generally, working in Thailand requires a work visa.
working online with non Thai customers is sometimes seen as not really working "in Thailand".
the actual law isn't so clear. but an immigration officer can probably deny you entry if you say that you work online. unless your visa specifically allows for it.. which I think some types of DTV do allow iirc
In case it is not, I assume you will need to require a re-entry permit before you leave. Can usually be done either at the airport or at the immigration.