There are a few parts to this.
The environment is specified by the --env CLI flag:
docpad <action> will run in the development environment
docpad <action> --env static will run in the static environment
docpad <action> --env production will run in the production environment
Now the default configuration is actually assumed to be the configuration for your production environment, with the development, static, and whatever other environment actually extending your default (production) configuration via the environments configuration property. You can see the special environment configuration the DocPad core specifies here.
Plugins will also specify custom environment configuration as well. So for instance the clean urls plugin will by default just rely on the DocPad node.js server to do the clean urls, but if we are running in a static environment, then it will write special static redirect files instead. Here is the code for how it does it.