Is it riskier to have surgery for asd when a child is younger or older?

Depends. The answer depends on the size and type of asd. In general, we often wait until the child is a few years as asds pose no emergency during that time (as long as there aren't other major medical conditions). The surgery is better tolerate and technically more successful when they are older. But again, this depends on whether the child has any other issues.
20+ pounds. Is when ASD closure in the cath lab can be safely performed. In some patients it might be done earlier. Waiting much longer does not reduce the risk but increases the likelihood for later rhythm problems.
Older. There is very little risk to ASD repair at any time during childhood. If an ASD is not repaired before adolescence, there is higher risk that the heart will not fully recover.