We show how a quasi-smooth derived enhancement of a Deligne-Mumford stack X naturally endows X with a functorial perfect obstruction theory in the sense of Behrend-Fantechi. This result is then applied to moduli of maps and perfect complexes on a smooth complex projective variety. For moduli of maps, for X = S an algebraic K3-surface, g ∈ N, and β = 0 in H 2 (S, Z) a curve class, we construct a derived stack RM red g,n (S; β) whose truncation is the usual stack M g,n (S; β) of pointed stable maps from curves of genus g to S hitting the class β, and such that the inclusion M g (S; β) ֒→ RM red g (S; β) induces on M g (S; β) a perfect obstruction theory whose tangent and obstruction spaces coincide with the corresponding reduced spaces of Okounkov-Maulik-Pandharipande-Thomas [O-P2, M-P, M-P-T]. The approach we present here uses derived algebraic geometry and yields not only a full rigorous proof of the existence of a reduced obstruction theory -not relying on any result on semiregularity maps -but also a new global geometric interpretation. We give two further applications to moduli of complexes. For a K3-surface S we show that the stack of simple perfect complexes on S is smooth. This result was proved with different methods by Inaba ([In]) for the corresponding coarse moduli space. Finally, we construct a map from the derived stack of stable embeddings of curves (into a smooth complex projective variety X) to the derived stack of simple perfect complexes on X with vanishing negative Ext's, and show how this map induces a morphism of the corresponding obstruction theories when X is a Calabi-Yau threefold. An important ingredient of our construction is a perfect determinant map from the derived stack of perfect complexes to the derived stack of line bundles whose tangent morphism is, pointwise, Illusie's trace map for perfect complexes. We expect that this determinant map might be useful in other contexts as well.