All that I am writing is from the Gita Press translation of the Srimad Valmiki Ramayan.
After Lakshman drops off Sita and returns to the chariot he is very sad. Then Sumantra (the minister and not the mata) tells this story. According to Sumantra Dashrathji knew that these sad episodes will happen in Ramji's life. One day Dashrathji goes to Vashista's ashram to meet him. There he sees Durvasa muni. Dashrathji asks Durvasa muni about his sons and their bhavishya. Durvasa muni then tells this story.
When the Daityas are vanquished by the devas they seek shelter at Sage Bhrgu's ashram. Sage Bhrgu gives them shelter. Vishnuji is angered and severes Bhrgu's spouse's head with his discus. Bhrgu gets angry with this and curses Vishnuji and says that he will be born as a man and live apart from his wife for many years. Since Vishnuji needs to take an avatar to kill Ravan, he accepts the curse and transforms the curse to separation after the coronation.
So, according to Sumantra, Dhashrathji knew that Ram was Vishnu's incarnation and that he will live apart from his wife after the coronation. Dashrathji keeps it a secret and takes the secret with him when he dies. Sumantra also knows about this because he goes to Vasishta's ashrama on that day with Dashrathji. Now, he tells Lakshman that and Lakshman now knows the secret of Ramji's birth, that is he is an avatar of Vishnu.