The rapid growth of Internet of Things (IoT) technology has revolutionized industrial and manufacturing sectors, with the Industrial Internet of Things (IIoT) playing a central role in enhancing operational efficiency. However, IIoT applications are challenged by limited computational and power resources, which impact the Quality of Service (QoS) requirements. While cloud computing alleviates some of these challenges, it introduces latency and server overload, leading to delays in task processing. Fog computing offers a promising solution by reducing latency and deploying computationally capable nodes at the network edge. This paper proposes a novel framework for optimizing task offloading in IIoT environments by focusing on intelligent resource allocation and profit maximization within a fog computing architecture. Unlike traditional methods, our approach integrates a unified cost function that simultaneously addresses task delay and energy consumption, improving efficiency by balancing these conflicting objectives. We present an Integer Linear Programming (ILP) model that minimizes the total offloading cost while adhering to strict power and resource constraints. To handle the NP-hard nature of ILP problems, we introduce a computationally efficient approximation method based on rounding techniques, achieving near-optimal solutions without excessive computational overhead. A key novelty of our work is the inclusion of profit maximization for IIoT application providers, which is often overlooked in existing solutions. We develop a second ILP model specifically for profit optimization, supported by an efficient solution method. Additionally, we propose a strategic resource expansion algorithm that adapts to insufficient system resources, ensuring the alignment of available resources with application demands. Our simulations demonstrate the practical impact of this approach, showcasing significant improvements in task processing time and energy efficiency, as well as optimizing profitability in real-world IIoT applications.