How easy it will be to replace a battery will depend on the device you’re working with. It can be a simple process involving a single screw, or an incredibly complicated enterprise that requires you to disassemble your entire computer and melt an incredibly sticky adhesive while you try not to break anything.
If the battery starts to fail within the warranty period, the easiest thing to do is to contact the manufacturer, as they might cover the part and the replacement. If your warranty is expired, you can take your device to a repair store—or replace the battery yourself.