What does "cock of all jests" mean?
Solution 1:
In an 1855 edition of "The Church Porch," edited by the Reverend Robert Willmott (incumbent of Bear Wood), the editor reports that the line
And the sad man is cock of all his jests.
actually means
The serious man wins the victory.
To reach that conclusion, one must first recognize that the stanza is comparing the virtues of a solemn or sober ("sad wise") valour to a giggling flightiness. The giggler begins to look bad from the moment "infection" or "a fir'd beacon" frightens him into silence—at which point, in the eyes of the assembled company, he becomes the object of scorn and derisive jest. Thus the serious ("sad") man triumphs ("is cock of all his jests").
Confirming this view is a footnote to the same stanza by Ascott Hope, A Book of Boyhoods (1882), reporting of the word sad in the first and last lines of the stanza,
This word then [in Herbert's time] implied serious, sober.
In a 1905 edition of Herbert's works, the editor, George Palmer, reads the final line of the stanza a bit more demonstratively:
It is the serious person who can crow at the end of the merriment. "He laughs best who laughs last."
So rather than meaning "The sad man is the butt of all his [the giggler's] jests," the final line means very nearly the opposite: "In the end, the serious man becomes the strutting (or crowing) champion of the biggest celebration."
Incidentally, Graham Greene used the line "And the sad man is cock of all his jests" as the epigraph to his novel Our Man in Havana (1958).
Solution 2:
It's based on:
cock (noun):
3 a : one occupying a position of success and control : victor; often : one dominating some field or leading some circle usually through determined aggressive individual effort
Merriam Webster Unabridged Dictionary
A joke that is better than most, that dominates the others.