While some will say "it's just supply and demand" and companies charge "whatever the market will bear", I'm not convinced that your comparison is fair to try and determine whether bikes are overpriced relative to motorcycles. Using a $4,000+ road bike and comparing it to a $3,000 motorcycle is comparing the upper end of one product to the lower end of another.
For example - you can go to performancebike.com and buy a reasonable entry-level road bike for around $800 ($500 or less if you watch for sales). That bike will have an aluminum frame, low-end carbon fork and a hodge-podge of low-end components.
Similarly, you can buy a low-end 2013 Honda CBR 250R at a list of $4,199. That motorcycle has a relatively small engine and will likely will have heavier components.
Both of those products are consumer focused, recreational products; not high-level competition machines.
If you move to the upper end of the recreational products, you are looking at $2,800 for a full carbon with mid-level components on the bike side, versus, $14,000 for the CBR 1000 on the motorcycle side. Neither of these is anywhere near the upper-end of competition ready products.
If you look at the relative percent difference in price, it about 250% between base and mid-level models of both products. It's up to the individual consumer to decide whether the added benefit of lighter materials, better components on the bike side, and more power, better component on the motorcycle side is really worth a 250% increase in price, but that's why manufacturers release a range of models.
If you want to compare between the products, the base motorcycle is going to cost you a little over 5 times what a base bicycle will cost (not counting add-ons like insurance, gas and maintenance). The prices of the higher level motorcycle and bicycle are at about the same ratio.
Finally, I don't know anything about use of composites in motorcycles, but I think it's debatable that the technology in a motorcycle requires significantly more R&D than for a bicycle. Precision shifting, weight minimization, not to mention the fabrication of carbon frame tubes to be light, strong, and exhibit directional dependent stiffness and flexibility is R & D intensive. This Gizmodo article explains in more detail why carbon fiber products are more expensive (hat-tip to Tom77) As far as I can find there are no stock motorcycles available with carbon frames, and Ducati sold a replica Desmosedici with a carbon seat support for over $70,000.