The script would have to save the ID metadata an then open the JPEG in PS and add it to Photoshop's info object there. I don't see any way to include it in the JPEG export.
If you export as PDF then open the PDF into Photoshop, the InDesign metadata is included. There are a number of quality issues with InDesign exported JPEGs, so PDF to PS to JPEG script might be a better approach anyway.
Don't know if it will help, but here is an AppleScript (OSX only) that exports a JPEG via PDF and keeps the metadata:
Here's a thread on the quality issue.
Thak you rob for so generously sharing your script! I think this is brilliant! I know very little about applescript and currently your script names final files with a page number. 01-filename 02-filename Could you kindly point me in a direction of how to name my files using either text styled with a specific paragraph style or with text in a particular frame. filename-myspecialtext filename-morespecialtext
I think this should be discussed in the Adobe InDesign Scripting Forum:
A starter could be this script snippet by Hans-Gerd Claßen, that is writing metadata directly to all placed images of an InDesign document.
It's using the AdobeXMPScript library. No need to switch over to PhotoShop or Adobe Bridge.