The course is concerned with theoretical and numerical aspects of optimization problems under PDE (partial differential equation) type constraints. More precisely, the objective function depends indirectly on the optimization variable through the so-called state function which is the solution of a PDE where the optimization variable appears in the data. Optimization variables can be finite-dimensional parameters, functions or geometric entities (for example, the shape of the domain). The existence of optimal solutions, the calculation of the sensitivity or gradient of the objective function with respect to the optimization variable and the numerical approximation of the solutions will be treated in this course. Applications in optimal control theory, shape optimization, inverse problems, data assimilation, sensitivity analysis and uncertainty quantification will be discussed. The use of the adjoint method to calculate the derivative of the objective function will be presented in details in several contexts. Numerical simulations using the FreeFEM software will illustrate the results presented in this course.