While taxpayers who run online businesses from the United States are generally subject to income tax and state sales tax (depending on the nature of the business, the primary location of their customer base, etc.) no specific guidance exists on foreign-based online businesses catering to U.S. customers when it comes to online personal services. These kinds of services may range from creating content for online websites, writing code for software, editing photos or other services which produce digital goods.
Publication 519 U.S. Tax Guide for Aliens covers a range of topics relating to the taxation of non-U.S. residents including source of income and what it means to be engaged in a trade or business in the United States. Nonresident aliens are taxed based on the source of their income and whether or not their income is effectively connected with a U.S. trade or business. In regards to personal services, you are considered to be engaged in a trade or business during the tax year in the United States if you perform personal services in the United States at any time during the tax year. See IRC § 861; Treas. Reg. 1.864-4. Pursuant to Internal Revenue Code § 862, where a nonresident alien performs personal services that generate digital goods in a foreign country, even if the digital goods are utilized by U.S. persons, the nonresident alien would not be considered engaged in a trade or business in the United States and therefore the income generated would not be income that is effectively connected with a U.S trade of business.