I noticed that my WiFi had similar repeating lags .. about every 8-10s pings would go to a few hundred ms and then return to single/low double digits.
Long story short, the problem was with several MacOS components (and maybe some 3rd party software) requesting Location services to determine Mac’s position. To do that, among other things, Mac scans WiFi around you (probably for the names/SSID?) and to do that, the current WIFI connection is temporarily put on a back burner, resulting in a brief delay in traffic. The solution was to minimize location services.