Smart ocean cities are crucial to future city development, and offshore networks are an essential part of smart ocean cities. Nowadays, communication in offshore networks is becoming increasingly important. However, the offshore networks are highly heterogeneous, with low reliability, narrow bandwidth, and dramatic dynamics. Offshore networks are more challenging to manage than traditional terrestrial networks, and the standard quality of service routing faces significant challenges. Currently, artificial intelligence provides a way to meet the requirements. This paper proposes ER-OCN (Efficient Routing in Ocean City Networks), a two-stage routing optimization scheme driven by artificial intelligence to cope with the complex offshore networks environment. The first stage will calculate the flow paths based on Lagrangian relaxation. Besides, the ocean environment is under dramatic dynamics, leading to unpredictable network topology or link bandwidth changes. Thus, the second stage deployed a deep reinforcement learning algorithm to monitor the environment in real-time and update the routing strategy when needed. We conducted experiments based on actual network topology and traffic data sets of offshore platforms’ network systems. The results prove that our scheme improves communication cost performance by 36.61% compared to traditional methods.