Legally, you will almost definitely need a license. In fact, pretty much all fan merch (including fanart) is technically illegal or at least in a legal gray area - there is little preventing companies with copyright ownership from striking down on such things, other than bad publicity.
That said, there is a general unspoken agreement, especially for Japanese anime and manga, that companies will turn a blind eye to small-scale operations* (like doujinshi, or some con-goer selling a few dozen postcards of fanart), as those will mostly help spread word-of-mouth and generally cannot serve to meaningfully replace official tat.
Problems occur with:
- Large-scale operations
- Unofficial merch with official art
- When someone explicitly seeks permission from the copyright holder.
1 should be obvious - large scale operations, particularly of merch (less so with doujinshi or fanfiction, insofar as they can be "large-scale"), may significantly threaten the profits of the copyright holder by replacing their own merch of the same type.
2, in addition to more flagrant infringement, has the possibility of fooling people into thinking that they are official.
3 is a bit complicated - if the copyright holder gives explicit permission without a license, even to a pure-intentioned fan, apparently it may weaken their legal position when an actually problematic copyright infringement issue occurs. Thus, upon such inquiries, companies are often forced to make a public statement that selling fan creations are not allowed - which has caused cancellations of multiple single-work conventions.
In short, technically you do need a license (and I don't expect Kodansha or such to give out licenses to individual fans), but practically companies will typically not bother fans selling fan art pins or such merch in a small scale - although as with all unspoken rules, YMMV.
However, if you plan on using official art or sell on an industrial level, you may find yourself in some trouble.
*As an aside, this legal limbo is part of why you will often find unscrupulous merchants stealing fanart and slapping them on their merch to brazenly sell online or at cons - their dubious legal position makes artists hesitant to seek recourse.