With the rapid development of intelligent devices, the intelligence of buildings is becoming more and more obvious, which leads to the rapid growth of data generated by building users. The existing network bandwidth is far from enough for the transmission of existing data, which will lead to congestion in the process of data transmission. In this paper, a task offloading strategy based on edge computing is proposed. The edge server is deployed near the data source, which mainly solves the problems of transmission delay and energy consumption of building users during task offloading. In this paper, the mathematical model of system delay and energy consumption is established first. In order to better reflect the quality of the system, the delay and energy consumption are combined into system utility, and then the objective function is established. Since the objective function is a mixed integer nonlinear programming problem, finding the optimal solution usually requires exponential time complexity. Therefore, this paper firstly uses the Tammer decomposition method to decouple the objective function, and decomposes it into the resource allocation problem of fixed task offloading decision and the task offload problem of maximizing the objective function. Then the convex optimization (CO) theory is used to greatly reduce the complexity of the objective function and optimize the resource allocation problem. Finally, the task offloading problem is solved by the improved Harris Hawks Optimization (HHO). The paper compares various offloading schemes. The simulation results show that the CO–HHO offloading strategy based on edge computing proposed in this paper can effectively reduce the transmission delay and energy consumption of user tasks in intelligent buildings, and is superior to others in all aspects.