Although young children are welcome at Mass, the obligation to attend does not bind those under seven years old. The Church’s law obligating Catholics to go to Mass is canon 1247: “On Sundays and other holy days of obligation, the faithful are obliged to participate in the Mass. Moreover, they are to abstain from those works and affairs which hinder the worship to be rendered to God, the joy proper to the Lord’s Day, or the suitable relaxation of mind and body.”
This law does not expressly state an age at which the faithful become obliged to follow it, but canon 11 tells us, “Merely ecclesiastical laws bind those who have been baptized in the Catholic Church or received into it, possess the efficient use of reason, and, unless the law expressly provides otherwise, have completed seven years of age.”
So, since canon 1247 (a merely ecclesiastical law) does not expressly provide otherwise, it binds only those who have completed seven years of age (and who also meet the other requirements mentioned in canon 11).