Let me begin this answer by saying that the best time to start with your UPSC Mock test series is right at the beginning of your preparation itself. Even before you have started with your syllabus. Then of course, as the exams come nearer and nearer, you should solve more and more mocks with increasing seriousness, making sure to do so as if solving a real exam.
Solving a mock test before starting your preparation would tell you where you are weak and where you are strong. Then you start your preparation accordingly. And after a while, again take a mock to gauge you strengths and weaknesses, and then carry on with your prep again.
Repeat this process until you’ve no weaknesses left. After that, right before the exams, you can sit down to take even more mock tests, solving them whilst imitating actual exam conditions.