This paper describes a method for selecting and adapting the model structure online while running together with a real-time optimization algorithm using Output Modifier Adaptation. The method chooses, among several knowledge-based models, the model structure that is most consistent with the current process data. By allowing the model to change over time, its structure and complexity are able to adapt to the plant data. Competing models are compared based on the modifiers, which are also used by the Output Modifier Adaptation to drive the system to the optimal operating point. The approach is demonstrated on two case studies: a continuous stirred tank reactor and a gas-lifted oil well network. In both cases, the best model structure is chosen among several candidates, and the plant optimum is reached without constraint violations. The case studies indicate that even with a significant amount of noise the modifiers are good indicators for which competing model structures to choose.