First of all: when it comes to the age of a language, there is a difference to be observed in dating by means of actual things, that still exist and other methods based on other evidence. Speaking about the first one, we are talking mostly about rock inscriptions, since these are quite durable and judged by these, Sanskrit and Tamil are approximately of the same age, since there are Ashoka Edicts from the 3rd century BCE as well as mostly Buddhist rock inscriptions in Tamil from about the same time.
Now, the second. If you date the age of a text, like Tolkappiyam or the Vedas, you have to rely on other evidence, since the surviving manuscripts are for the most part much younger than the text itself. Here it is quite without doubt, that the oldest books of the Rig-Veda are the oldest texts in Sanskrit and are much older than Tolkappiyam. This is based mostly on linguistic evidence. But fact is, that the literary history of Sanskrit, at least what we know of it, is much older than that which we know of Tamil. The Tolkappiyam itself is heavily indebted to the Sanskrit grammatical tradition and must therefore be younger.
Now about Ramayana and Mahabharata periods: are you talking about the period, when these texts were composed or the period that they are supposedly talking about? If the first: the Mahabharata was composed somewhere between 400 BCE and 400 CE and the Ramayana somewhere between 300 BCE and 200 CE. These datings are of course to some extent speculative but are the best guesses that are based on real evidence and not wishful thinking. So of course in these times, Tamil must have been spoken, since for example the Sangam literature (itself starting maybe around 150 BCE or a bit later) presupposes a literary development that must have happened before the first poems and should therefore go back to somewhere around maybe 300 BCE. This is about literature which again presupposes spoken language.
If you are asking about the era, that the epics are playing in, the question is much harder to answer, since it is not clear, what that time should be in the first place.
Please note, that all this talk is about literary testimonies of languages, not about languages itself. Think about it this way: early Sanskrit-speakers (if there ever were) and Tamil-speakers did not fall from heaven, they had ancestors, that also spoke a language and so on. So the question which language is older (not talking about which literature is older here), at least in the case of languages not yet proven to be related in any way, as is the case with Sanskrit and Tamil, does not make too much sense. Which literature is older? Sorry to say, but it clearly is Sanskrit.