In this study, a semi-analytical numerical method, the scaled boundary finite element method, is employed to investigate the time-dependent behaviour of pile foundations when subjected to ocean wave loads. Individual piles present steady-state vibrations at the same frequency as external waves considering the material damping effect. In the case with a group of two piles, the structural behaviour of pile foundations is a multivariable function of the wave properties and the spatial arrangement of piles, and each pile responses differently to various parameter combinations. The leading pile, which interacts with incoming waves earlier, normally experiences greater displacement amplitude than the subsequent pile. Both piles show relatively greater displacement in cases with large wave numbers. When the two piles are closely spaced or when the wave number is small, their responses tend to have phase difference and move towards different directions. This study is expected to shed light on the transient behaviour of pile foundations, when wave load is a dominant factor.