Plankton occupy a vital place in the marine ecosystem due to their essential role. However small or microscopic, their absence can bring the entire life process to a standstill. In this work, we have proposed a prey–predator ecological model consisting of phytoplankton, zooplankton, and fish, incorporating the cannibalistic nature of zooplankton harvesting the fish population. Due to differences in their feeding habits, zooplankton are divided into two sub-classes: herbivorous and carnivorous. The dynamic behavior of the model is examined for each of the possible steady states. The stability criteria of the model have been analyzed from both local and global perspectives. Hopf bifurcation analysis has been accomplished with the growth rate of carnivorous zooplankton using cannibalism as a bifurcation parameter. To characterize the optimal control, we have used Pontryagin’s maximum principle. Subsequently, the optimal system has been derived and solved numerically using an iterative method with Runge–Kutta fourth-order scheme. Finally, to facilitate the interpretation of our mathematical results, we have proceeded to investigate it using numerical simulations.