Hi there,
The JR Pass can be used on all national JR trains, including on all Shinkansen lines. In terms of local city transport in Osaka and Tokyo, the JR Pass can be used on the JR Yamanote line in Tokyo and the Osaka Loop line in Osaka, but for the other metro lines you'll need to use a prepaid travel card such as a SUICA or PASMO.
This means that the pass can be used to travel via Shinkansen from Osaka to Tokyo, but if that is the only Shinkansen trip of your trip then my suggestion would be to just purchase it individually as it is likely to be your most cost-effective option. In terms of how to actually use the JR Pass, see our blog post here.
Kind regards,
Alexis