Post-starburst (E+A or k+a) spectra, characterized by their exceptionally strong Balmer lines in absorption and the lack of emission lines, belong to galaxies in which the star formation activity ended abruptly sometime during the past Gyr. We perform a spectral analysis of galaxies in clusters, groups, poor groups and the field at z=0.4-0.8 based on the ESO Distant Cluster Survey. The incidence of k+as at these redshifts depends strongly on environment. K+as reside preferentially in clusters and, unexpectedly, in a subset of the sigma = 200-400 km/s groups, those that have a low fraction of [OII] emitters. In these environments, 20-30% of the recently star-forming galaxies have had their star formation activity recently truncated. In contrast, there are proportionally fewer k+as in the field, the poor groups and groups with a high [OII] fraction. The incidence of k+a galaxies correlates with the cluster velocity dispersion: more massive clusters have higher proportions of k+as. Spectra of dusty starburst candidates, with strong Balmer absorption and emission lines, present a very different environmental dependence from k+as. They are numerous in all environments at z=0.4-0.8, but they are especially numerous in all types of groups, favoring the hypothesis of triggering by a merger. Our observations are consistent with previous suggestions that cluster k+a galaxies are observed in a transition phase as massive S0 and Sa galaxies, evolving from star-forming later types to passively evolving early-type galaxies. The correlation between k+a fraction and cluster sigma supports the hypothesis that k+a galaxies in clusters originate from processes related to the intracluster medium, while several possibilities are discussed for the origin of the k+a frequency in low-[OII] groups.(abr.)