Ontology is a knowledge depiction archetypal that provides the semantic services which are the most challenging task on the emergent cutting-edge technology such as IoT. The dynamic sensing capability with adapting the semantic structure to the sensed data gains precise attention from the research community. The semantic approach solves the issue of interoperability applied to the heterogeneous sensed data across different application domains. Generating ontologies from the heterogeneous sensed data sources based on real-time application needs an effective mechanism due to the rising demand for the public participation. We propose an effective technique for generating ontology by adopting the Fruit fly optimization algorithm. The proposed approach proves that the construction of ontology-based information increases the logistics of the system effectively with a low operating cost.