Hello,
Thanks for reaching out!
That will depend on the theme you’re using. For example, Storefront already includes a search bar in the header. But you should be able to add a Product Search block to any widget area that your theme provides in Appearance > Customize > Widgets.
If your theme doesn’t have a widget area suitable for your objectives, you could try a theme compatible with Full Site Editing (like Twenty Twenty Two) where you’ll be able to fully customize your header area. See how to use the new WordPress site editor here.
Please let us know if we can be of any further assistance.