We study the effect of temperature up to 1000K on the structure of dense molecular para-hydrogen and ortho-deuterium, using the path-integral Monte Carlo method. We find a structural phase transition from orientationally disordered hexagonal close packed (hcp) to an orthorhombic structure of Cmca symmetry before melting. The transition is basically induced by thermal fluctuations, but quantum fluctuations of protons (deuterons) are important in determining the transition temperature through effectively hardening the intermolecular interaction. We estimate the phase line between hcp and Cmca phases as well as the melting line of the Cmca solid.