Gerhard has a wonderful discussion of allegories in his treatise On Interpreting Sacred Scripture. This section alone is worth the price of admission. Though his treatment is brief, it is a treasury of homiletical gems, and I will only discuss its barest outlines here. Indeed, it contains most everything that it took me years of seminary and experience to figure out about whether allegory may be used and if so, how. For the most part my experience has been that modern exegetes are hostile to allegorizing. Gerhard knew this debate well:
The fathers were fairly profuse in their allegories, while some today are fairly hostile to them. So what should be decided about allegories?Gerhard warns that it is very easy to stray from the rule of faith when allegorizing (we're looking at you, Origen). He navigates the proper use of allegory in a few ways. He starts by noting the rhetorical distinction between a type and an allegory. What Paul is doing in Gal. 4:24, for example, is actually typology though he uses the term "allegory." Likewise, the fathers sometimes misuse these terms.
Next, Gerhard also insists that the literal meaning of Scripture in context is the meaning of the Holy Spirit (excepting those places where the Holy Spirit Himself interprets things allegorically or typologically). That is the basis of all exegesis and from it one can draw "various teachings, exhortations, consolations, and refutations against adversaries." For Gerhard all good allegory is simply responsible application of the text. Modern exegetes who shun allegory should consider rethinking their position along these lines. The original meaning of the text comes first, then in teaching and preaching you also have to apply it to your hearers (allegorize).
Gerhard then offers pointers on how best to allegorize. "The goal of all Scripture is Christ," urges Gerhard. "In allegories, therefore, it is His office, His benefits, and His reign that should be explained most of all." Furthermore, don't allegorize the moral Law like the Ten Commandments. Don't look for allegory everywhere. Do look for allegory in the ceremonial law and in historical narratives provided that you also maintain the facts of the actual events. Often both a type and an allegory can come from the same passage. For example, the account of David and Goliath is about Christ defeating the Devil (typology) and may be applied to the godly man overcoming the lusts of the flesh through faith (allegory). There are even times when allegory is demanded by the text or it will be especially advantageous to do so (when teaching the account of Jacob, Laban, Leah, and Rachel to your Sunday school kids your best bet is to go for the allegorical interpretation!)
Gerhard further notes how allegory makes for good preaching that is Bible rich and not dry or filled with cheeky stories:
When used appropriately and sparingly, allegories delight, stimulate, and remove tedium, which is why they are especially well suited for sermon openings [exordiis]. One must work tirelessly to make allegories appropriate, firstly and foremost that they be analogous to the faith.This must be why Gerhard always starts his sermons with a type or allegory from the OT that pertains to the Sunday Gospel.
Finally, because allegory can be and has been greatly abused, Gerhard also gives sober warnings:
Be sure, however, not to search too far for allegories, for then they will be crude and inane. Be sure they do not militate against the chief parts of the historical account that we want to treat allegorically. Do not dwell on them longer than they deserve; instead, approach them gracefully, simply touching upon them with a few words subtly and discreetly. Let them not be too intricate or perplexing. In short, it is not for everyone to appropriately and fittingly use allegories. Those who are less practiced in them should proceed soberly and prudently. Those who make use of allegories hastily and without discernment can easily propose something that the learned will contemn, the vicious will mock, and that will cause the weak to stumble. Undoubtedly Origen was rebuked by the ancients on this charge.