In a fundus photograph, morphological changes of the optic disc and cup are crucial for diagnosing optic neuropathy. To achieve an accurate pixel-wise segmentation of the optic disc and cup, the domain-specific knowledge such as the oval shape constraint has not been sufficiently explored in most of the existing methods, leading to unacceptable geometric distortions in many cases. Few attempts try to consider the general convexity constraint or specific building geometric properties, but they are still not suitable for the typical oval shape segmentation. In this paper, an oval shape constraint based loss function (OS-loss) is proposed to improve the existing deep learning network for segmenting optic disc and cup. A penalty point set is proposed to represent unreasonable contour points of a target object using the oval shape constraint. These points will be penalized and integrated into the training loss function of the baseline network. Further, an oval-friendly metric called shape error (SE) is proposed to better reflect the fitness of two oval contours. Experiments on the public RIM-ONE-r3 dataset with 159 fundus photographs and a private W10K dataset with 9,879 fundus photographs prove the effectiveness of the proposed OS-loss function. Compared to the original CE-net, the mean error of the Cup to Disc Ratio (CDR) of the proposed OS-loss method in the RIM-ONE-r3 dataset decreases 1.98%. In the W10K dataset, the mean CDR error decreases by 1.03% for the ResU-net and decreases by 2.1% for the CE-net.