In this paper, we investigate the optimal control of the Burgers equation. For both optimal distributed and (Neumann) boundary control problems, the Dubovitskii and Milyutin functional analytical approach is adopted in investigation of the Pontryagin maximum principles of the systems. The necessary optimality conditions are, respectively, presented for two kinds of optimal control problems in both fixed and free final horizon cases, four extremum problems in all. Moreover, in free final horizon case, the assumptions of admissible control set on convexity and non-empty interior are removed so that it can be any set including an interesting case contains only finite many points Finally, a remark on how to utilize the obtained results is also made for the illustration.