First-half tries from Lewis Ludlow, Jonny May, Darren Dawidiuk and a Heinz double earned the hosts a bonus point.
Heinz completed his treble and further tries from Andy Symons, Henry Purdy, Josh Hohneck and Callum Braley ensured Gloucester finished top of Pool One.
Martin Laveau scored a hat-trick of his own in response for Bayonne.
The Cherry and Whites, winners of the competition in 2015, suffered just one defeat from six group games, with their convincing victory over the French Top 14's bottom side their third successive win in all competitions.
Gloucester: Marshall; Sharples, Symons, Twelvetrees, May; Burns, Heinz (capt); Thomas, Dawidiuk, Afoa, Savage, Thrush, Ludlow, Rowan, Evans.
Replacements: Walker, Hohneck, Doran-Jones, Latta, Kvesic, Braley, Scott, Purdy.
Bayonne: Tisseron; Laveau, Fuster, Lacroix, Tongia; Meret, Duhalde; Bordenave, Labouyrie, Taufa, Ducat, Jaulhac, Lespinasse, Marmouyet (capt), Polutele.
Replacements: Ayarza, Iguiniz, Khinchagishvili, Evrard Oulai, Muscarditz, Saubusse, Mamao, Duputs.
Referee: Lloyd Linton (Scotland)
For the latest rugby union news follow @bbcrugbyunion on Twitter.
Willi Heinz scored a hat-trick as Gloucester ran in 10 tries against Bayonne to secure a European Challenge Cup home quarter-final.