Do I need to be in the United States to apply for H4-EAD based on my H-4 status?
If yes, can I travel outside USA while my H4-EAD application is pending?
To be in USA to file H4-EAD?
Yes, you need to be physically present in USA to apply for H4-EAD.
This is based on the premise that you should have valid H4 status at the time you file your H4-EAD.
Travel outside USA while H4-EAD is pending?
You can travel outside USA after filing for H4-EAD and application is still pending (not approved yet).
What could happen if you travel outside USA while H4-EAD application is pending
-
Could cause delays in your case. : While you are outside of the United States, USCIS may need additional information to make a decision on your H4-EAD application or they may issue a Notice of Intent to Deny (NOID) with an opportunity to respond.
If you do not respond on time to a Request for Evidence (RFE) or to the NOID, they may deny your case as abandoned. -
If you filed H4-EAD concurrently with H-4 change-of-status from a different non-immigrant classification (like your own current H1B to H4), USCIS will straight-away deny your change-of-status application (Form I-539) as abandoned.
In this case, they would also deny your H4-EAD and you will need to a file a new H4-EAD once you re-enter USA and get your H4 status approved.
Source: USCIS FAQ for H4-EAD