In this article we apply the optimal andthe robust control theory to the sine-Gordon equation. In our casethe control is given by the boundary conditions and we work in a finitetime horizon. We present at the beginning the optimal control problemand we derive a necessary condition of optimality and we continue byformulating a robust control problem for which existence and uniquenessof solutions are derived.