To reduce loss of tooth tissue and to improve esthetic results, inlay and onlay restorations are good treatment choices for extensive cavities in posterior teeth. The aim of this paper was to evaluate, by means of three-dimensional finite element analysis, the effects of restorative material and cavity design on stress distribution in the tooth structures and restorative materials. Two different nanofilled composites and two different all-ceramic materials were used in this study. A permanent molar tooth was modeled with enamel and dentin structures. 3-D inlay and onlay cavity designs were created. Von Mises, compressive, and tensile stresses on the restorative materials, core materials, enamel, and dentin were evaluated separately. On the effect of restorative material, results showed that in the case of materials with low elastic moduli, more stress was transferred to the tooth structures. Therefore, compared to the nanofilled composites, the all-ceramic inlay and onlay materials tested transferred less stress to the tooth structures. On the effect of cavity design, the onlay design was more efficacious in protecting the tooth structures than the inlay design.