We study the optimal design problem for sampling functional data. The goal is to find optimal time points for sampling functional data so that the full underlying true function can be accurately predicted. A similar problem occurs in functional regression, where the goal is to find optimal time points for sampling functional predictor in order to accurately predict the outcome of interest. The problems are motivated by the fetal growth study, where the objective is to determine the optimal times to collect ultrasound measurements and the number of ultrasound measurements that are needed to recover fetal growth trajectories or to predict child birth outcomes. Under the frameworks of functional principal component analysis and functional linear models, we formulate both problems as a unified optimization problem and the solution provides the optimal design points. We also propose a simple method for selecting the number of optimal sampling points. Performance of the proposed method is thoroughly investigated via a simulation study and by its application to fetal ultrasound.