If you failed to attache Schedule B, but the final totals on form B did appear on the main 1040 form, then the IRS will send you a notice for the missing form. They will provide instructions on how to submit the form.
If you failed to consider schedule B, and the final numbers didn't appear on the main 1040 form, then a 1040X will be need to correct the situation.
The 1040X is used to correct the information. But if you didn't attach a form it is likely that the IRS can't process the forms as submitted and will be requesting the missing information.
Here is some info from the IRS:
Topic No. 308 Amended Returns
If you discover an error after filing your return, you may need to
amend your return. The IRS may correct mathematical, clerical errors
on a return and may accept returns without certain required forms or
schedules. In these instances, there's no need to amend your return.
However, do file an amended return if there's a change in your filing
status, income, deductions, credits or tax liability. Use Form 1040-X,
Amended U.S. Individual Income Tax Return to correct a previously
filed Form 1040, Form 1040-SR, Form 1040A, Form 1040EZ, Form 1040-NR,
Form 1040-NR-EZ, or to change amounts previously adjusted by the IRS.
You can also use Form 1040-X to make a claim for a carryback due to a
loss or unused credit; however, you may also be able to use Form 1045,
Application for Tentative Refund instead of Form 1040-X. Also, if the
Form 8938, Statement of Specified Foreign Financial Assets applies to
you, file it with an annual return or an amended return. See the
Instructions for Form 8938 for more information.
That webpage has a link to a tool: Should I File an Amended Return? that will help you decide.