As Dave Tweed said, here in the US about the only legal requirement for something that doesn't contain a RF transmitter (classified as unintentional radiator by the FCC) is a set of maximum radiation standards. There is a limit as to how much power the device is allowed to put out over a range of freuencies. There are also conducted emission limits for noise your device dumps back onto the power line if it is plugged into power during normal operation. There is no legal requirement that you get the device tested, only that it meet the requirements.
Unless you have some fairly sophisticated and properly calibrated and maintained equipment, you can't really test this yourself. There are testing houses all over the country that perform such testing, usually for a few $k per test. Again, getting the product tested is not a requirement, but if someone complains and the FCC decides to check it out and then finds it emitting beyond the limits, you're in trouble. This can include confiscation of all product and sometimes fines. Things will go easier if you show that you made a reasonable attempt to check for emissions and found the product to pass. One way to do that is to produce a test report from one of the test houses.
In practise for a simple product you sell in small volumes on your web site, this isn't really a issue. The FCC doesn't go looking for trouble, they react to someone complaining. As long as you follow reasonable design principles, generally meaning to get someone that knows what they are doing and can spell "RF" to design the circuit and lay out the board, you're not likely to be enough above the limit where anyone will notice.
There have been cases where harmless-seeming equipment interfered with important RF communication. I remember a case where a TV antenna amplifier intended for boats could start oscillating. This happened to jam GPS signals within a significant distance. The Coast Guard and several harbor masters complained, so the FCC investigated and eventually tracked the problem to the badly designed antenna amplifier. Needless to say, the antenna amplifier company then had a "unpleasant encounter" with the FCC.
There are a few other notable legal requirements in some areas, particularly in the EU. The europeans got a bug up their butt about the lead used in solder. This has spread to California too now. If you're in a jurisdiction that doesn't have the lead ban, then you can legally sell your product on your web site even if it contains lead. They can't come after you, but they could in theory confiscate your product when it enters their jurisdiction. Again, for a small guy selling a low volume item on a web site this is not a issue in practise unless you are actually located in the EU or California.
If your product has wall power in it somewhere, then you have to think more carefully about what you want to do. For a small guy, the simple answer is just don't do that. Buy or specify a external power supply that someone else makes and is already certified. Your unit then only handles isolated low voltage DC, and you can basically ignore this issue. UL or equivalent testing and certification is quite expensive, 10s of $k, so this is basically inaccessible to the little guy.
If your product includes a RF transmitter or it is a medical device, then the above does not apply and things get a lot more complicated. Anyone that has to ask here has no business trying to produce a medical device. If that's what you were thinking, then you're in way over your head. Forget about it and go home. If a transmitter, then including someone else's pre-certified module is the only way, but even that gets complicated and you have to have someone on board that actually knows what they are doing. Again, the simple answer is go home and forget about it.