That is a teaching from the Commentaries, not the Tipitaka.
There are some reports of lay disciples in the Tipitaka who attained enlightenment and in all cases they either ordained or passed away within 7 days. The Commentaries made it a 'compulsory' action, but it is not found or described that way in the Tipitaka.
But in defense of the Commentaries, it does make sense. Once a lay person is enlightened, there probably would not be any more attachment to the lay life of worldly affairs of career, family, etc. The passing away in 7 days is not something that must happen, it is probably just that in some cases the enlightened person did not get the chance to ordain due to passing away too quickly after enlightenment.