Sixth-tier Macclesfield, who knocked out holders Crystal Palace in the previous round, frustrated their Premier League opponents in the first half.
Goalkeeper Max Dearnley made some fine saves, denying Brentford's Reiss Nelson from close range. Macclesfield's James Dawson came closest to scoring for the hosts with a long-range effort that sailed just wide.
After the break, Brentford increased the pressure, forcing Dearnley to react quickly to keep out Kaye Furo's close-range header. However, the goalkeeper was beaten when Heathcote inadvertently headed Aaron Hickey's cross into his own net while attempting to clear in the 70th minute.
The result secured Brentford a fifth-round tie against West Ham United. Macclesfield bowed out of the competition after a brilliant run and another strong performance against top-flight opposition.
