The integration of fog computing within the Internet of Things (IoT) ecosystem necessitates advanced solutions for optimizing task scheduling to enhance responsiveness and resource utilization effectively. Traditional methods often struggle to dynamically adapt to the fluctuating demands of fog computing environments, particularly in minimizing latency and optimizing energy consumption. This paper introduces the Octopus Adaptive Intelligence Algorithm (OAIA), a novel approach inspired by the highly adaptive behaviors of octopuses. OAIA dynamically adjusts task allocations based on real-time changes in environmental conditions and workloads, aiming to optimize resource utilization and reduce response times. The innovation of OAIA lies in its flexible, condition-responsive mechanism that allows for continuous tuning of scheduling parameters in response to varying task demands and node capacities. This adaptive capability ensures the rapid processing of latency-sensitive tasks by utilizing the proximity of fog nodes and efficiently manages latency-tolerant tasks within the cloud. The performance of OAIA was rigorously evaluated through a series of controlled simulations within a fog computing environment, examining its response to different variables such as the number of tasks, fog nodes, cloud nodes, and the maximum number of iterations. Empirical results from these simulations demonstrate that OAIA not only effectively handles increasing complexities and adapts to varied resource distributions but also significantly improves fitness scores—indicative of enhanced latency, energy consumption, and resource utilization—compared to traditional scheduling strategies. Our comparative results reveal that OAIA consistently outperforms established algorithms such as Particle Swarm Optimization (PSO) and Genetic Algorithms (GA) in achieving lower fitness values, indicative of more efficient task management. These findings underscore the potential of adaptive algorithms in efficiently managing the complex and variable demands of fog computing systems, setting the stage for future advancements in intelligent task scheduling for IoT environments. This study paves the way for further exploration into adaptive and intelligent solutions that can cater to the nuanced needs of modern fog computing frameworks, enhancing their efficacy and applicability across diverse real-world applications.