We prove continuity of certain cost functions arising from optimal control of affine control systems. We give sharp sufficient conditions for this continuity. As an application, we prove a version of weak KAM theorem and consider the Aubry–Mather problems corresponding to these systems.