Previously the Apostle had banned carnal sins by threatening punishment and rejecting a fallacy (5:6). Here he gives the reason; it is taken from their situation.
Thus he remarks you were heretofore darkness blinded by ignorance and error. "Having their understanding darkened" (Eph. 4:18). "They have not known nor have they understood; they walk on in darkness" (Ps. 81:5). The darkness also comes from sin: "The way of the wicked is darksome; they know not where they fall" (Prov. 4:19). But observe that he does not vaguely call them "darksome" but darkness. For anyone appears to be whatever is... predominant in him; thus the whole state appears to be the king and whatever the king does is said to be done by the state, likewise when sin dominates a man the entire person is referred to as sin and darkness.
Next he describes their present condition, as though he said: But now you enjoy the light of faith: "among whom you shine as lights in the world" (Phil. 2:15), for "you are the light of the world" (Mt. 5:14). But this contradicts what was said of John the Baptist: "He was not the light" (Jn. 1:8). How then can other believers be called the light? I reply. They are not referred to as the light in essence but through participation.
He affirms: Since you are now light, perform the deeds of light—Walk as children of the light. "Walk whilst you have the light, that the darkness overtake you not" (Jn. 12:35).
Source: Commentary on Ephesians