Sophocles's life spanned the time from approximately 496 to 405 BC. During his long life, the polis of Athens, of which he was a citizen, was involved in the two most famous wars of its history.
When Sophocles was a child, Athens and other Greek poleis were involved in their war against the Persian Empire. This was the war in which the famous battles of Marathon and Thermopylae and Salamis occurred. Sophocles was probably too young to have participated in this conflict as he was about 16 when it ended.
Much later in Sophocles' life, the Peloponnesian War erupted, pitting Athens against Sparta as the main antagonists. This war lasted from 431 until the year after Sophocles died.