DTerm uses these rules to determine its working directory:

If the frontmost window belongs to the Finder, the working directory is set to the “target” directory of the window, if available. This is the directory displayed in the title bar of the window.

Otherwise, if a list of selected items can be obtained from the frontmost application, the working directory is set to the directory which contains the first selected item.

Otherwise, DTerm uses your home directory as its working directory. This generic DTerm window will appear at the top of the screen to distinguish it from DTerm windows which were able to derive their working directories from the frontmost window.