The optimal time for a fetal echocardiogram is between 18 and 22 weeks of gestation. However, if there are concerns regarding connective tissue diseases or cardiac rhythm disturbances, it is important to perform this procedure during the second and third trimesters of pregnancy as well.