President Juan Carlos Varela said the decision was necessary as Costa Rica and Nicaragua had recently closed their borders to Cubans heading north.
Panama has also agreed to transfer more than 3,500 Cubans hoping to reach the US to a town in northern Mexico.
President Varela said the flights to Mexico could last two to three weeks.
The Cubans have been stranded in Panama for months.
They are hoping to reach the US under a decades-old law which gives them privileged entry and a fast track to residency.
The number of Cubans trying to reach the US has increased lately because of fears that warming relations between the two countries could mean the end of the preferential treatment they receive.
Key crossings on Panama's border with Colombia are to be closed to control the flow of Cuban migrants heading to the United States.