In recent years, the emergence of Internet of things and cyber-physical system provide a proactive and efficacious solution to enable remote monitoring, machine learning-based analytics, and quick decision making for real-time applications. Cloud supported systems still face Quality of Service issues for implementing time-sensitive applications. Introducing 5G network services by revolutionizing existing technologies can increase communication efficiency and provide optimum trade-offs for connected IoT devices. In this paper, NFV, ONV, and SDN is used to create a computational OpticalFog node in the middleware of cloud and edge that provides an ecosystem to facilitate an ultra-fast infrastructure in the 5G network. The main aim behind the proposed system is to (1) exploit the computational potential of optical resources to create an OpticalFog node to be integrated into the 5G network infrastructure for CPS-based applications, (2) present an algorithm for optimum placement that provide service assurance to various CPS-based applications, and (3) enable CPS-based applications, which are able to run on top of the OpticalFog and 5G infrastructure. Therefore, a case study based on the deployment surveillance system in an academic institute using the proposed system is presented. iFogSim toolkit is used to implement the proposed OpticalFog-based deployment for the surveillance cameras. The results show the significant advantages of the proposed system for CPS-based applications in the 5G network.