This paper presents the development and application of the unsteady continuous adjoint method to the incompressible Navier-Stokes equations and its use in two different optimization problems. The first is the computation of the optimal setting of a flow control system, based on pulsating jets located along the surface of a square cylinder, in order to minimize the time-averaged drag. The second is dealing with unsteady topology optimization of a duct system with four fixed inlets and a single outlet, with periodic in time inlet velocity profiles, where the target is to minimize the time-averaged viscous losses. The presentation of the adjoint formulation is kept as general as possible and can thus be used to other optimization problems governed by the unsteady Navier-Stokes equations. Though in the examined problems the flow is laminar, the extension to turbulent flows is doable.