To avoid surface recombination at the contacts and ensure efficient charge collection and high open-circuit voltages (VOC) in organic bulk heterojunction and perovskite solar cells, selective contacts with optimized energy levels are needed. However, a detailed theoretical understanding of how the device performance is affected by surface recombination at the contacts is still lacking. In this work, the influence of surface recombination on the open-circuit voltage in sandwich-type solar cells, with optically thin active layers, is clarified using numerical simulations. Furthermore, analytical expressions are derived, directly relating VOC to relevant device parameters, such as surface recombination velocity (Sp), mobility, and active layer thickness. At large Sp, the surface recombination is determined by diffusion-limited transport in the bulk. By reducing Sp, thus increasing the charge selectivity of the electrode, the surface recombination is eventually reduced as the transport becomes limited by interface kinetics at the contact. Depending on the interplay between surface recombination and bulk recombination, and the properties of the contacts, different operating regimes are identified featuring different light ideality factors and thickness dependences.