The quote appears in Season 4, Episode 6: "Window of Opportunity" (the "Groundhog Day" loop episode). As the loop resets, O'Neill (Richard Dean Anderson) reads from a book:
"Violence is the last refuge of the incompetent."
Source: Foundation (1951) by Isaac Asimov — spoken by character Salvor Hardin. It encapsulates the episode's theme: O'Neill solves the time loop through intellect and persistence, not force.