How long does it typically take Boeing to make a new plane model (e.g the 787), from the moment they decide to make a plane (the moment they decide to create a new 7X7) to the moment the first plane (in this case the first 787) flies commercially?
For the general question, the answer will be "it depends on the aircraft." Specifically for the 787, though, the '7E7' program was officially announced on January 29, 2003. The program was later renamed to 787. It received its type certificate on August 26, 2011 and flew its first passenger revenue flight on October 26, 2011.
So, from the time the program began to the time of the first revenue flight was about 8 years and 9 months.
Of course, this is not including the R&D time invested on different projects whose R&D ended up being used either partially or completely in the 787 design before the 787 program itself began.
It should also be noted that not every airframe they start developing ever actually flies. Notably, Boeing worked on designs including larger 747 variants and the Sonic Cruiser (which would have cruised at Mach 0.98) before beginning the 7E7 program.
In addition to completely new airframes, aircraft manufacturers also commonly make derivative airframes based on existing product families. Current examples of derivatives in development include the 737MAX, A320neo, 777X, and A330neo ("neo" stands for "new engine option.") However, development time on derivatives can vary widely depending on how much modification is being made to the existing airframes and the level of resources being devoted to the project (which depends on market pressure.)
For a past example, the 2nd-generation Boeing 777 aircraft were announced on February 29, 2000 with the first aircraft, the 777-300ER, being certificated on March 16, 2004, and first service entry on May 10, 2004. This gives a time of about 4 years and 2 months from announcement to first service entry. This was likely slowed by the sharp downturn in aircraft orders following the 1999-2000 ".com bust" and, especially, the September 11, 2001 terrorist attacks in the U.S.
Also important is the FAA rule for applying for a type certificate. This will apply for new programs like the 787, but not for derivative programs like the 777X, which amend the original type certificate and do not need a new one. In 14 CFR §21.17:
An application for type certification of a transport category aircraft is effective for 5 years and an application for any other type certificate is effective for 3 years...
So once Boeing applies for a new type certificate, they have 5 years to get the type cetificate approved, unless they convince the FAA upfront that more time is needed. If the time runs out they must reapply, and the new type certificate would require the aircraft to comply with all new regulations passed since their original application.