This work provides a real-time algorithmic optimal control framework for autonomous switched systems. Traditional optimal control approaches for autonomous switched systems are open-loop in nature. Therefore, the switching times of the system can not be adjusted or adapted when the system parameters or the operational environments change. This work aims to close this loop, and apply adaptations to the optimal switching strategy based on new information that can only be captured on-line. One important contribution of this work is to provide the means to allow feedback (in a general sense) to the control laws (i.e. the switching times) of the switched system so that the control laws can be updated to maintain optimality of the switching-time control inputs. Furthermore, convergence analysis for the proposed algorithms are presented. The effectiveness of the real-time algorithms is demonstrated by an application in optimal formation and coverage control of a networked system. This application is implemented on a realistic simulation framework consisting of a number of Unmanned Aerial Vehicles (UAVs) that interact in a virtual 3D world.