The full potential of pile optimization has not been realized as the interactions between superstructures and foundations, and the relationships between material usage and foundation performance are rarely investigated. This paper introduces an analysis and optimization approach for pile group and piled raft foundations, which allows coupling of superstructure stiffness with the foundation model, through a condensed matrix representing the flexural characteristics of the superstructure. This coupled approach is implemented within a multi-objective optimization algorithm, capable of providing a series of optimized pile configurations at various amounts of material. The approach is illustrated through two case studies. The first case involves evaluation of the coupled superstructure–foundation analyses against field measurements of a piled raft–supported building in London, UK. The potential benefits of pile optimization are also demonstrated through re-analyses of the foundation by the proposed optimization approach. In the second case, the effects of a soft storey on the superstructure–foundation interactions are investigated. These cases demonstrate the importance of properly considering the superstructure effects, especially when the building consists of stiff components such as concrete shear walls. The proposed approach also allows engineers to make informed decisions on the foundation design, depending on the specific project finances and performance requirements.