The analysis of an optimal control problem of nonlocal type is analyzed. The results obtained are applied to the study the corresponding local optimal control problems. The state equations are governed by p-laplacian elliptic operators, of local and nonlocal type, and the costs belong to a wide class of integral functionals. The nonlocal problem is formulated by means of a convolution of the states with a kernel. This kernel depends on a parameter, called horizon which, is responsible for the nonlocality of the equation. The input function is the source of the elliptic equation. Existence of nonlocal controls is obtained and a G-convergence result is employed in this task. The limit of the solutions of the nonlocal optimal control, when the horizon tends to zero, is analyzed and compared to the solution of the underlying local optimal control problem.