We present an extension of some results of higher order calculus of variations and optimal control to generalized functions. The framework is the category of generalized smooth functions, which includes Schwartz distributions, while sharing many nonlinear properties with ordinary smooth functions. We prove the higher order Euler-Lagrange equations, the DAlembert principle in differential form, the du Bois-Reymond optimality condition and the Noethers theorem. We start the theory of optimal control proving a weak form of the Pontryagin maximum principle and the Noethers theorem for optimal control. We close with a study of a singularly variable length pendulum, oscillations damped by two media and the Pais-Uhlenbeck oscillator with singular frequencies.