How Chocolate Can Fit Into a Weight-Loss Plan
Chocolate does not need to disappear from your food log when you want to lose weight. The useful approach is to plan for it, notice how much satisfies you and consider your overall intake.
Look at the whole pattern
Body weight is influenced by your overall energy balance over time, not by one food in isolation. Chocolate can fit when the rest of your eating pattern supports the goal you have set.

Keep tracking chocolate as you would anything else, including the portion you actually eat. Its energy content varies by type and serving size, so use the label or your tracking app rather than guessing.
Choose a portion on purpose
Decide how much chocolate you plan to have before you begin eating it. Putting that portion in a small bowl or on a plate can make the amount clearer than eating directly from a larger pack.

There is no ideal portion that suits everyone. The amount that fits depends on your energy needs, usual meals, activity and personal target, so use your log to see how it sits within your day.
Make it satisfying
Eat chocolate slowly enough to notice its flavour, texture and sweetness. Having it without scrolling, working or watching something can help you pay attention to whether you still want more.

Choose the chocolate you genuinely enjoy rather than picking one simply because it sounds more virtuous. A planned serving of a favourite variety may feel more satisfying than repeatedly eating alternatives that do not meet the same craving.
Learn from your food log
Review your entries for patterns rather than judging a single day. You might notice that chocolate is easier to enjoy as planned after a filling meal, or that keeping it visible leads you to eat it without much thought.
If your planned amount often turns into more, adjust the setting rather than labelling yourself as lacking willpower. You could log the portion in advance, keep the remainder out of sight, or make room for chocolate by changing another optional part of the day.