We describe a three-dimensional (3D) finite element analysis model of the contact between an atomic force microscopy (AFM) tip and a substrate with finite size subsurface structures. The model can simulate the contact stiffness measured by a scanning AFM tip on the surface of a sample with buried nanoscale structures. In addition to the analytical verification and convergence analysis, we present the results of an experimental verification study. For this purpose, we use an atomic force acoustic microscopy setup and special silicon samples with well defined subsurface cavities fabricated by focused ion beam techniques. The 3D model is also used for parametric analysis of subsurface defect detection, and imaging simulations are performed for practical applications such as AFM imaging of electromigration defects.