In this paper, we investigate a distributed optimization problem in multi-agent systems, where the cost function is a sum of local cost functions associated with individual agents. Inspired by the outstanding performance of proportional- integral-derivative (PID) controllers in the field of control, we propose the Distributed PID Optimization Algorithm (D-PID) based on output feedback to solve the distributed optimization problem. We aim to establish the exponential convergence of the D-PID algorithm over undirected connected graphs when the local objective functions are smooth and strongly convex. Additionally, we provide guidelines for selecting appropriate parameter values (e.g., $K_{p}, K_{i}$ , and $K_{d}$ ) and analyze the correctness of the algorithm over time-varying interaction graphs. To further reduce unnecessary communication resource consumption, we develop the Distributed PID Optimization Algorithm with Time-Triggered Scheme (D-PID-TT). We theoretically demonstrate that D-PID-TT can converge to an optimal solution at a global exponential convergence rate under the same conditions as D-PID. We also provide guidelines for parameter selection and specify the communication period. Furthermore, we show that the D-PID has great potential for nonconvex distributed optimization. Finally, we present numerical simulations to verify the effectiveness and superiority of our proposed algorithms.