It’s a good question really.
The real answer is no. You can’t export to H.264 from your production codec (ProRes, or in your case DVCProHD) without a loss of quality. There will always be *some* loss due to compression.
But what you can do is make good choices along the way and minimize the effect of compression.
So, what I would suggest is use the best encoder out there for H.264: x264. It’s used by all the big players (encoding.com, YouTube, Netflix, Hulu, etc.) not just because open-source and free to use but because it’s the most tuneable and produces the best image per bitrate.
Luckily for us, there’s an easy and free way to use it: Handbrake (https://handbrake.fr).
Export your master to ProRes if needed, or drop your DVCProHD into it and choose your preset. It comes with a set of Production presets (standard, max, etc.) which should do you just fine, and will do all the x264 tuning for best quality.
For uploads to web services, like YouTube or Twitter, the service will re-encode your video, so why not give them the best you can before they compress the hell out of it for their delivery?
If you want to take this to the next level, you can build in an Export to Handbrake command from FCPX. I’ve got instructions on how here:
http://fsorvin.freeshell.org/01articles/2017-03-06_export_to_handbrake.html
Hope that’s helpful.
Flemming