many many ways, I recommend doing a search, quite a few threads on the topic. I, personally, am keen to cocoa powder (100% no additives/sugars/etc.). I usually add to secondary, if not enough at bottling time, I'll put a little more in before bottling. Always boil a little water first and add th powder to that, then add the chocolate water to the brew.
You can add at boiling time as well. A little cocoa and lactose can make for an excellent addition to a stout